Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 10486 invoked from network); 20 Jul 2010 01:10:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 20 Jul 2010 01:10:01 -0000 Received: (qmail 31919 invoked by uid 500); 20 Jul 2010 01:10:01 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 31886 invoked by uid 500); 20 Jul 2010 01:10:01 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 31879 invoked by uid 99); 20 Jul 2010 01:10:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jul 2010 01:10:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jul 2010 01:09:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2926523889B3; Tue, 20 Jul 2010 01:08:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r965704 - in /directory/apacheds/trunk: ./ core-api/src/main/java/org/apache/directory/server/core/ core-integ/src/test/java/org/apache/directory/server/core/collective/ core-integ/src/test/java/org/apache/directory/server/core/subtree/ cor... Date: Tue, 20 Jul 2010 01:08:20 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100720010821.2926523889B3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Tue Jul 20 01:08:19 2010 New Revision: 965704 URL: http://svn.apache.org/viewvc?rev=965704&view=rev Log: merged back the subtree branch into trunk Removed: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java directory/apacheds/trunk/i18n/src/test/java/org/apache/directory/server/i18n/ directory/apacheds/trunk/i18n/src/test/resources/org/apache/directory/server/i18n/ Modified: directory/apacheds/trunk/ (props changed) directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyConfiguration.java (props changed) directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/ (props changed) directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java (props changed) directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/ (props changed) directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java (props changed) directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java (props changed) directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (props changed) directory/apacheds/trunk/server-config/src/main/resources/ (props changed) directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java (props changed) directory/apacheds/trunk/test-framework/ (props changed) Propchange: directory/apacheds/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,3 +1,4 @@ /directory/apacheds/branches/apacheds-replication:749790-764110 /directory/apacheds/branches/apacheds-schema:806623-896441 +/directory/apacheds/branches/apacheds-subtree:965203-965686 /directory/apacheds/branches/xdbm-refactoring:945827-946347 Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java Tue Jul 20 01:08:19 2010 @@ -540,6 +540,33 @@ public class LdapCoreSessionConnection i /** * {@inheritDoc} */ + public ModifyResponse modify( DN dn, Modification... modifications ) throws LdapException + { + ModifyResponse resp = new ModifyResponse(); + resp.setLdapResult( getDefaultResult() ); + + try + { + List mods = new ArrayList(); + + for ( Modification modification : modifications ) + { + mods.add( modification ); + } + session.modify( dn, mods ); + } + catch ( Exception e ) + { + resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) ); + } + + return resp; + } + + + /** + * {@inheritDoc} + */ public ModifyResponse modify( Entry entry, ModificationOperation modOp ) throws LdapException { ModifyResponse resp = new ModifyResponse(); Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java (original) +++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java Tue Jul 20 01:08:19 2010 @@ -25,27 +25,36 @@ import static org.junit.Assert.assertEqu import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.util.HashMap; import java.util.Map; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -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 javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; +import org.apache.directory.ldap.client.api.LdapConnection; +import org.apache.directory.ldap.client.api.message.AddResponse; +import org.apache.directory.ldap.client.api.message.ModifyResponse; +import org.apache.directory.ldap.client.api.message.SearchResponse; +import org.apache.directory.ldap.client.api.message.SearchResultEntry; import org.apache.directory.server.core.integ.AbstractLdapTestUnit; import org.apache.directory.server.core.integ.FrameworkRunner; +import org.apache.directory.server.core.integ.IntegrationUtils; +import org.apache.directory.shared.ldap.cursor.Cursor; +import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute; +import org.apache.directory.shared.ldap.entry.DefaultModification; +import org.apache.directory.shared.ldap.entry.Entry; +import org.apache.directory.shared.ldap.entry.EntryAttribute; +import org.apache.directory.shared.ldap.entry.ModificationOperation; import org.apache.directory.shared.ldap.exception.LdapException; +import org.apache.directory.shared.ldap.filter.SearchScope; import org.apache.directory.shared.ldap.ldif.LdapLdifException; import org.apache.directory.shared.ldap.ldif.LdifUtils; +import org.apache.directory.shared.ldap.message.ResultCodeEnum; +import org.apache.directory.shared.ldap.name.DN; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -58,9 +67,12 @@ import org.junit.runner.RunWith; @RunWith ( FrameworkRunner.class ) public class CollectiveAttributeServiceIT extends AbstractLdapTestUnit { - private Attributes getTestEntry( String cn ) throws LdapLdifException, LdapException + private static LdapConnection connection; + + private Entry getTestEntry( String dn, String cn ) throws LdapLdifException, LdapException { - Attributes subentry = LdifUtils.createAttributes( + Entry subentry = LdifUtils.createEntry( + new DN( dn ), "objectClass: top", "objectClass: person", "cn", cn , @@ -70,9 +82,10 @@ public class CollectiveAttributeServiceI } - private Attributes getTestSubentry() throws LdapLdifException, LdapException + private Entry getTestSubentry( String dn ) throws LdapLdifException, LdapException { - Attributes subentry = LdifUtils.createAttributes( + Entry subentry = LdifUtils.createEntry( + new DN( dn ), "objectClass: top", "objectClass: subentry", "objectClass: collectiveAttributeSubentry", @@ -84,9 +97,10 @@ public class CollectiveAttributeServiceI } - private Attributes getTestSubentry2() throws LdapLdifException, LdapException + private Entry getTestSubentry2( String dn ) throws LdapLdifException, LdapException { - Attributes subentry = LdifUtils.createAttributes( + Entry subentry = LdifUtils.createEntry( + new DN( dn ), "objectClass: top", "objectClass: subentry", "objectClass: collectiveAttributeSubentry", @@ -98,9 +112,10 @@ public class CollectiveAttributeServiceI } - private Attributes getTestSubentry3() throws LdapLdifException, LdapException + private Entry getTestSubentry3( String dn ) throws LdapLdifException, LdapException { - Attributes subentry = LdifUtils.createAttributes( + Entry subentry = LdifUtils.createEntry( + new DN( dn ), "objectClass: top", "objectClass: subentry", "objectClass: collectiveAttributeSubentry", @@ -114,64 +129,90 @@ public class CollectiveAttributeServiceI private void addAdministrativeRole( String role ) throws Exception { - Attribute attribute = new BasicAttribute( "administrativeRole" ); - attribute.add( role ); - ModificationItem item = new ModificationItem( DirContext.ADD_ATTRIBUTE, attribute ); - getSystemContext( service ).modifyAttributes( "", new ModificationItem[] { item } ); + EntryAttribute attribute = new DefaultEntryAttribute( "administrativeRole", role ); + + connection.modify( new DN( "ou=system" ), new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attribute ) ); } - private Map getAllEntries() throws Exception + private Map getAllEntries() throws Exception { - Map resultMap = new HashMap(); - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - controls.setReturningAttributes( new String[] - { "+", "*" } ); - NamingEnumeration results = getSystemContext( service ).search( "", "(objectClass=*)", controls ); + Map resultMap = new HashMap(); + + Cursor cursor = + connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "+", "*" ); - while ( results.hasMore() ) + while ( cursor.next() ) { - SearchResult result = results.next(); - resultMap.put( result.getName(), result.getAttributes() ); + SearchResponse result = cursor.get(); + + if ( result instanceof SearchResultEntry ) + { + Entry entry = ((SearchResultEntry)result).getEntry(); + resultMap.put( entry.getDn().getName(), entry ); + } } + return resultMap; } - private Map getAllEntriesRestrictAttributes() throws Exception + private Map getAllEntriesRestrictAttributes() throws Exception { - Map resultMap = new HashMap(); - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - controls.setReturningAttributes( new String[] - { "cn" } ); - NamingEnumeration results = getSystemContext( service ).search( "", "(objectClass=*)", controls ); - while ( results.hasMore() ) + Map resultMap = new HashMap(); + + Cursor cursor = + connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "cn" ); + + while ( cursor.next() ) { - SearchResult result = results.next(); - resultMap.put( result.getName(), result.getAttributes() ); + SearchResponse result = cursor.get(); + + if ( result instanceof SearchResultEntry ) + { + Entry entry = ((SearchResultEntry)result).getEntry(); + resultMap.put( entry.getDn().getName(), entry ); + } } + return resultMap; } - private Map getAllEntriesCollectiveAttributesOnly() throws Exception + private Map getAllEntriesCollectiveAttributesOnly() throws Exception { - Map resultMap = new HashMap(); - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - controls.setReturningAttributes( new String[] - { "c-ou", "c-st" } ); - NamingEnumeration results = getSystemContext( service ).search( "", "(objectClass=*)", controls ); + Map resultMap = new HashMap(); + + Cursor cursor = + connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "c-ou", "c-st" ); - while ( results.hasMore() ) + while ( cursor.next() ) { - SearchResult result = results.next(); - resultMap.put( result.getName(), result.getAttributes() ); + SearchResponse result = cursor.get(); + + if ( result instanceof SearchResultEntry ) + { + Entry entry = ((SearchResultEntry)result).getEntry(); + resultMap.put( entry.getDn().getName(), entry ); + } } + return resultMap; } + + + @Before + public void init() throws Exception + { + connection = IntegrationUtils.getAdminConnection( service ); + } + + + @After + public void shutdown() throws Exception + { + connection.close(); + } @Test @@ -180,25 +221,27 @@ public class CollectiveAttributeServiceI // ------------------------------------------------------------------- // Setup the collective attribute specific administration point // ------------------------------------------------------------------- - addAdministrativeRole( "collectiveAttributeSpecificArea" ); - getSystemContext( service ).createSubcontext( "cn=testsubentry", getTestSubentry() ); + Entry subentry = getTestSubentry( "cn=testsubentry,ou=system" ); + connection.add( subentry ); // ------------------------------------------------------------------- // test an entry that should show the collective attribute c-ou // ------------------------------------------------------------------- - Attributes attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" ); - Attribute c_ou = attributes.get( "c-ou" ); + SearchResponse response = connection.lookup( "ou=services,ou=configuration,ou=system" ); + Entry entry = ((SearchResultEntry)response).getEntry(); + EntryAttribute c_ou = entry.get( "c-ou" ); assertNotNull( "a collective c-ou attribute should be present", c_ou ); - assertEquals( "configuration", c_ou.get() ); + assertEquals( "configuration", c_ou.getString() ); // ------------------------------------------------------------------- // test an entry that should not show the collective attribute // ------------------------------------------------------------------- - attributes = getSystemContext( service ).getAttributes( "ou=users" ); - c_ou = attributes.get( "c-ou" ); + response = connection.lookup( "ou=users,ou=system" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); assertNull( "the c-ou collective attribute should not be present", c_ou ); // ------------------------------------------------------------------- @@ -211,65 +254,77 @@ public class CollectiveAttributeServiceI getSystemContext( service ).modifyAttributes( "ou=services,ou=configuration", items ); // entry should not show the c-ou collective attribute anymore - attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" ); - c_ou = attributes.get( "c-ou" ); + response = connection.lookup( "ou=services,ou=configuration,ou=system" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); + if ( c_ou != null ) { assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() ); } // now add more collective subentries - the c-ou should still not show due to exclusions - getSystemContext( service ).createSubcontext( "cn=testsubentry2", getTestSubentry2() ); + Entry subentry2 = getTestSubentry2( "cn=testsubentry2,ou=system" ); + connection.add( subentry2 ); + + response = connection.lookup( "ou=services,ou=configuration,ou=system" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); - attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" ); - c_ou = attributes.get( "c-ou" ); if ( c_ou != null ) { assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() ); } // entries without the collectiveExclusion should still show both values of c-ou - attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" ); - c_ou = attributes.get( "c-ou" ); + response = connection.lookup( "ou=interceptors,ou=configuration,ou=system" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); + assertNotNull( "a collective c-ou attribute should be present", c_ou ); assertTrue( c_ou.contains( "configuration" ) ); assertTrue( c_ou.contains( "configuration2" ) ); // request the collective attribute specifically + response = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "c-ou" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); - attributes = getSystemContext( service ).getAttributes( - "ou=interceptors,ou=configuration", new String[] { "c-ou" } ); - c_ou = attributes.get( "c-ou" ); assertNotNull( "a collective c-ou attribute should be present", c_ou ); assertTrue( c_ou.contains( "configuration" ) ); assertTrue( c_ou.contains( "configuration2" ) ); // unspecify the collective attribute in the returning attribute list + response = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "objectClass" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); - attributes = getSystemContext( service ).getAttributes( - "ou=interceptors,ou=configuration", new String[] { "objectClass" } ); - c_ou = attributes.get( "c-ou" ); assertNull( "a collective c-ou attribute should not be present", c_ou ); // ------------------------------------------------------------------- // now add the subentry for the c-st collective attribute // ------------------------------------------------------------------- - getSystemContext( service ).createSubcontext( "cn=testsubentry3", getTestSubentry3() ); + connection.add( getTestSubentry3( "cn=testsubentry3,ou=system" ) ); // the new attribute c-st should appear in the node with the c-ou exclusion - attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" ); - Attribute c_st = attributes.get( "c-st" ); + response = connection.lookup( "ou=services,ou=configuration,ou=system" ); + entry = ((SearchResultEntry)response).getEntry(); + EntryAttribute c_st = entry.get( "c-st" ); + assertNotNull( "a collective c-st attribute should be present", c_st ); assertTrue( c_st.contains( "FL" ) ); // in node without exclusions both values of c-ou should appear with c-st value - attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" ); - c_ou = attributes.get( "c-ou" ); + response = connection.lookup( "ou=interceptors,ou=configuration,ou=system" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); + assertNotNull( "a collective c-ou attribute should be present", c_ou ); assertTrue( c_ou.contains( "configuration" ) ); assertTrue( c_ou.contains( "configuration2" ) ); - c_st = attributes.get( "c-st" ); + + c_st = entry.get( "c-st" ); assertNotNull( "a collective c-st attribute should be present", c_st ); assertTrue( c_st.contains( "FL" ) ); @@ -283,13 +338,17 @@ public class CollectiveAttributeServiceI getSystemContext( service ).modifyAttributes( "ou=interceptors,ou=configuration", items ); // none of the attributes should appear any longer - attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" ); - c_ou = attributes.get( "c-ou" ); + response = connection.lookup( "ou=interceptors,ou=configuration,ou=system" ); + entry = ((SearchResultEntry)response).getEntry(); + c_ou = entry.get( "c-ou" ); + if ( c_ou != null ) { assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() ); } - c_st = attributes.get( "c-st" ); + + c_st = entry.get( "c-st" ); + if ( c_st != null ) { assertEquals( "the c-st collective attribute should not be present", 0, c_st.size() ); @@ -305,17 +364,17 @@ public class CollectiveAttributeServiceI // ------------------------------------------------------------------- addAdministrativeRole( "collectiveAttributeSpecificArea" ); - getSystemContext( service ).createSubcontext( "cn=testsubentry", getTestSubentry() ); + connection.add( getTestSubentry( "cn=testsubentry,ou=system" ) ); // ------------------------------------------------------------------- // test an entry that should show the collective attribute c-ou // ------------------------------------------------------------------- - Map entries = getAllEntries(); - Attributes attributes = entries.get( "ou=services,ou=configuration,ou=system" ); - Attribute c_ou = attributes.get( "c-ou" ); + Map entries = getAllEntries(); + Entry entry = entries.get( "ou=services,ou=configuration,ou=system" ); + EntryAttribute c_ou = entry.get( "c-ou" ); assertNotNull( "a collective c-ou attribute should be present", c_ou ); - assertEquals( "configuration", c_ou.get() ); + assertEquals( "configuration", c_ou.getString() ); // ------------------------------------------------------------------ @@ -324,18 +383,18 @@ public class CollectiveAttributeServiceI // ------------------------------------------------------------------ entries = getAllEntriesCollectiveAttributesOnly(); - attributes = entries.get( "ou=services,ou=configuration,ou=system" ); - c_ou = attributes.get( "c-ou" ); + entry = entries.get( "ou=services,ou=configuration,ou=system" ); + c_ou = entry.get( "c-ou" ); assertNotNull( "a collective c-ou attribute should be present", c_ou ); - assertEquals( "configuration", c_ou.get() ); + assertEquals( "configuration", c_ou.getString() ); // ------------------------------------------------------------------- // test an entry that should not show the collective attribute // ------------------------------------------------------------------- - attributes = entries.get( "ou=users,ou=system" ); - c_ou = attributes.get( "c-ou" ); + entry = entries.get( "ou=users,ou=system" ); + c_ou = entry.get( "c-ou" ); assertNull( "the c-ou collective attribute should not be present", c_ou ); // ------------------------------------------------------------------- @@ -349,27 +408,29 @@ public class CollectiveAttributeServiceI entries = getAllEntries(); // entry should not show the c-ou collective attribute anymore - attributes = entries.get( "ou=services,ou=configuration,ou=system" ); - c_ou = attributes.get( "c-ou" ); + entry = entries.get( "ou=services,ou=configuration,ou=system" ); + c_ou = entry.get( "c-ou" ); + if ( c_ou != null ) { assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() ); } // now add more collective subentries - the c-ou should still not show due to exclusions - getSystemContext( service ).createSubcontext( "cn=testsubentry2", getTestSubentry2() ); + connection.add( getTestSubentry2( "cn=testsubentry2,ou=system" ) ); entries = getAllEntries(); - attributes = entries.get( "ou=services,ou=configuration,ou=system" ); - c_ou = attributes.get( "c-ou" ); + entry = entries.get( "ou=services,ou=configuration,ou=system" ); + c_ou = entry.get( "c-ou" ); + if ( c_ou != null ) { assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() ); } // entries without the collectiveExclusion should still show both values of c-ou - attributes = entries.get( "ou=interceptors,ou=configuration,ou=system" ); - c_ou = attributes.get( "c-ou" ); + entry = entries.get( "ou=interceptors,ou=configuration,ou=system" ); + c_ou = entry.get( "c-ou" ); assertNotNull( "a collective c-ou attribute should be present", c_ou ); assertTrue( c_ou.contains( "configuration" ) ); assertTrue( c_ou.contains( "configuration2" ) ); @@ -378,22 +439,22 @@ public class CollectiveAttributeServiceI // now add the subentry for the c-st collective attribute // ------------------------------------------------------------------- - getSystemContext( service ).createSubcontext( "cn=testsubentry3", getTestSubentry3() ); + connection.add( getTestSubentry3( "cn=testsubentry3,ou=system" ) ); entries = getAllEntries(); // the new attribute c-st should appear in the node with the c-ou exclusion - attributes = entries.get( "ou=services,ou=configuration,ou=system" ); - Attribute c_st = attributes.get( "c-st" ); + entry = entries.get( "ou=services,ou=configuration,ou=system" ); + EntryAttribute c_st = entry.get( "c-st" ); assertNotNull( "a collective c-st attribute should be present", c_st ); assertTrue( c_st.contains( "FL" ) ); // in node without exclusions both values of c-ou should appear with c-st value - attributes = entries.get( "ou=interceptors,ou=configuration,ou=system" ); - c_ou = attributes.get( "c-ou" ); + entry = entries.get( "ou=interceptors,ou=configuration,ou=system" ); + c_ou = entry.get( "c-ou" ); assertNotNull( "a collective c-ou attribute should be present", c_ou ); assertTrue( c_ou.contains( "configuration" ) ); assertTrue( c_ou.contains( "configuration2" ) ); - c_st = attributes.get( "c-st" ); + c_st = entry.get( "c-st" ); assertNotNull( "a collective c-st attribute should be present", c_st ); assertTrue( c_st.contains( "FL" ) ); @@ -408,13 +469,16 @@ public class CollectiveAttributeServiceI entries = getAllEntries(); // none of the attributes should appear any longer - attributes = entries.get( "ou=interceptors,ou=configuration,ou=system" ); - c_ou = attributes.get( "c-ou" ); + entry = entries.get( "ou=interceptors,ou=configuration,ou=system" ); + c_ou = entry.get( "c-ou" ); + if ( c_ou != null ) { assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() ); } - c_st = attributes.get( "c-st" ); + + c_st = entry.get( "c-st" ); + if ( c_st != null ) { assertEquals( "the c-st collective attribute should not be present", 0, c_st.size() ); @@ -427,71 +491,41 @@ public class CollectiveAttributeServiceI entries = getAllEntriesRestrictAttributes(); // we should no longer see collective attributes with restricted return attribs - attributes = entries.get( "ou=services,ou=configuration,ou=system" ); - c_st = attributes.get( "c-st" ); + entry = entries.get( "ou=services,ou=configuration,ou=system" ); + c_st = entry.get( "c-st" ); assertNull( "a collective c-st attribute should NOT be present", c_st ); - attributes = entries.get( "ou=partitions,ou=configuration,ou=system" ); - c_ou = attributes.get( "c-ou" ); - c_st = attributes.get( "c-st" ); + entry = entries.get( "ou=partitions,ou=configuration,ou=system" ); + c_ou = entry.get( "c-ou" ); + c_st = entry.get( "c-st" ); assertNull( c_ou ); assertNull( c_st ); } @Test - public void testAddRegularEntryWithCollectiveAttribute() throws LdapException + public void testAddRegularEntryWithCollectiveAttribute() throws Exception { - Attributes entry = getTestEntry( "Ersin Er" ); + Entry entry = getTestEntry( "cn=Ersin Er,ou=system", "Ersin Er" ); entry.put( "c-l", "Turkiye" ); - try - { - getSystemContext( service ).createSubcontext( "cn=Ersin Er", entry ); - fail( "Entry addition with collective attribute should have failed." ); - } - catch ( Exception e ) - { - // Intended execution point - } + AddResponse response = connection.add( entry ); + + assertEquals( ResultCodeEnum.OBJECT_CLASS_VIOLATION, response.getLdapResult().getResultCode() ); } @Test public void testModifyRegularEntryAddingCollectiveAttribute() throws Exception { - Attributes entry = getTestEntry( "Ersin Er" ); - getSystemContext( service ).createSubcontext( "cn=Ersin Er", entry ); - Attributes changeSet = new BasicAttributes( "c-l", "Turkiye", true ); - try - { - - getSystemContext( service ).modifyAttributes( "cn=Ersin Er", DirContext.ADD_ATTRIBUTE, changeSet ); - fail( "Collective attribute addition to non-collectiveAttributeSubentry should have failed." ); - } - catch ( NamingException e ) - { - // Intended execution point - } - } - - - @Test - public void testModifyRegularEntryAddingCollectiveAttribute2() throws Exception - { - Attributes entry = getTestEntry( "Ersin Er" ); - getSystemContext( service ).createSubcontext( "cn=Ersin Er", entry ); - Attribute change = new BasicAttribute( "c-l", "Turkiye"); - ModificationItem mod = new ModificationItem(DirContext.ADD_ATTRIBUTE, change); - try - { - getSystemContext( service ).modifyAttributes( "cn=Ersin Er", new ModificationItem[] { mod } ); - fail( "Collective attribute addition to non-collectiveAttributeSubentry should have failed." ); - } - catch ( NamingException e ) - { - // Intended execution point - } + Entry entry = getTestEntry( "cn=Ersin Er,ou=system", "Ersin Er" ); + connection.add( entry ); + + ModifyResponse response = connection.modify( new DN( "cn=Ersin Er,ou=system" ), + new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, + new DefaultEntryAttribute( "c-l", "Turkiye" ) ) ); + + assertEquals( ResultCodeEnum.OBJECT_CLASS_VIOLATION, response.getLdapResult().getResultCode() ); } @@ -501,16 +535,17 @@ public class CollectiveAttributeServiceI // ------------------------------------------------------------------- // Setup the collective attribute specific administration point // ------------------------------------------------------------------- - addAdministrativeRole( "collectiveAttributeSpecificArea" ); - getSystemContext( service ).createSubcontext( "cn=testsubentry", getTestSubentry() ); + Entry subentry = getTestSubentry( "cn=testsubentry,ou=system" ); + connection.add( subentry ); // request the collective attribute's super type specifically - Attributes attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration", - new String[] { "ou" } ); - Attribute c_ou = attributes.get( "c-ou" ); + SearchResponse response = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "ou" ); + + Entry entry = ((SearchResultEntry)response).getEntry(); + + EntryAttribute c_ou = entry.get( "c-ou" ); assertNotNull( "a collective c-ou attribute should be present", c_ou ); assertTrue( c_ou.contains( "configuration" ) ); } - } Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java (original) +++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java Tue Jul 20 01:08:19 2010 @@ -331,7 +331,6 @@ public class SubentryServiceIT extends A } - @Test /** * Add a subentry under AP-A. * The following entries must be modified : @@ -356,6 +355,7 @@ public class SubentryServiceIT extends A * * Then suppress the subentry under AP-B */ + @Test public void testSubentryAdd() throws Exception { LdapConnection connection = IntegrationUtils.getAdminConnection( service ); @@ -812,6 +812,7 @@ public class SubentryServiceIT extends A Attributes configuration = results.get( "ou=configuration,ou=system" ); Attribute collectiveAttributeSubentries = configuration.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ); + if ( collectiveAttributeSubentries != null ) { assertEquals( "ou=configuration,ou=system should not be marked", 0, collectiveAttributeSubentries.size() ); @@ -819,6 +820,7 @@ public class SubentryServiceIT extends A Attributes interceptors = results.get( "ou=interceptors,ou=configuration,ou=system" ); collectiveAttributeSubentries = interceptors.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ); + if ( collectiveAttributeSubentries != null ) { assertEquals( "ou=interceptors,ou=configuration,ou=system should not be marked", 0, collectiveAttributeSubentries @@ -827,6 +829,7 @@ public class SubentryServiceIT extends A Attributes partitions = results.get( "ou=partitions,ou=configuration,ou=system" ); collectiveAttributeSubentries = partitions.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ); + if ( collectiveAttributeSubentries != null ) { assertEquals( "ou=partitions,ou=configuration,ou=system should not be marked", 0, collectiveAttributeSubentries.size() ); @@ -834,6 +837,7 @@ public class SubentryServiceIT extends A Attributes services = results.get( "ou=services,ou=configuration,ou=system" ); collectiveAttributeSubentries = services.get( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ); + if ( collectiveAttributeSubentries != null ) { assertEquals( "ou=services,ou=configuration,ou=system should not be marked", 0, collectiveAttributeSubentries.size() ); Propchange: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyConfiguration.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,3 +1,4 @@ /directory/apacheds/branches/apacheds-replication/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/PasswordPolicyConfiguration.java:749790-764110 /directory/apacheds/branches/apacheds-schema/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/PasswordPolicyConfiguration.java:806623-896441 +/directory/apacheds/branches/apacheds-subtree/core/src/main/java/org/apache/directory/server/core/authn/PasswordPolicyConfiguration.java:965203-965686 /directory/apacheds/branches/xdbm-refactoring/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/PasswordPolicyConfiguration.java:945827-946347 Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Tue Jul 20 01:08:19 2010 @@ -38,6 +38,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.partition.ByPassConstants; import org.apache.directory.server.core.schema.SchemaService; import org.apache.directory.shared.ldap.codec.controls.ManageDsaITControl; +import org.apache.directory.shared.ldap.constants.SchemaConstants; import org.apache.directory.shared.ldap.entry.DefaultEntry; import org.apache.directory.shared.ldap.entry.Entry; import org.apache.directory.shared.ldap.entry.EntryAttribute; @@ -165,12 +166,15 @@ public class ChangeLogInterceptor extend forward.setDn( deleteContext.getDn() ); Entry reverseEntry = new DefaultEntry( serverEntry.getDn() ); + + boolean isCollectiveSubentry = serverEntry.hasObjectClass( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRY_OC ); for ( EntryAttribute attribute : serverEntry ) { // filter collective attributes, they can't be added by the revert operation AttributeType at = schemaService.getSchemaManager().getAttributeTypeRegistry().lookup( attribute.getId() ); - if ( !at.isCollective() ) + + if ( !at.isCollective() || isCollectiveSubentry ) { reverseEntry.add( attribute.clone() ); } Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java Tue Jul 20 01:08:19 2010 @@ -21,6 +21,7 @@ package org.apache.directory.server.core import java.util.HashSet; +import java.util.List; import java.util.Set; import org.apache.directory.server.core.DirectoryService; @@ -37,16 +38,24 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.interceptor.context.SearchOperationContext; import org.apache.directory.server.core.interceptor.context.SearchingOperationContext; import org.apache.directory.server.core.partition.ByPassConstants; -import org.apache.directory.server.core.partition.PartitionNexus; +import org.apache.directory.server.i18n.I18n; import org.apache.directory.shared.ldap.constants.SchemaConstants; import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute; import org.apache.directory.shared.ldap.entry.Entry; import org.apache.directory.shared.ldap.entry.EntryAttribute; +import org.apache.directory.shared.ldap.entry.Modification; +import org.apache.directory.shared.ldap.entry.ModificationOperation; import org.apache.directory.shared.ldap.entry.Value; import org.apache.directory.shared.ldap.exception.LdapException; +import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeTypeException; +import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException; +import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.name.DN; import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.SchemaManager; +import org.apache.directory.shared.ldap.schema.SchemaUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -60,16 +69,21 @@ import org.apache.directory.shared.ldap. */ public class CollectiveAttributeInterceptor extends BaseInterceptor { + /** The LoggerFactory used by this Interceptor */ + private static Logger LOG = LoggerFactory.getLogger( CollectiveAttributeInterceptor.class ); + /** The SchemaManager instance */ private SchemaManager schemaManager; - - private PartitionNexus nexus; - - private CollectiveAttributesSchemaChecker collectiveAttributesSchemaChecker; + /** The ObjectClass AttributeType */ + private static AttributeType OBJECT_CLASS_AT; + /** The CollectiveAttributeSubentries AttributeType */ private static AttributeType COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT; - + + /** The CollectiveExclusions AttributeType */ + private static AttributeType COLLECTIVE_EXCLUSIONS_AT; + /** * the search result filter to use for collective attribute injection */ @@ -77,32 +91,239 @@ public class CollectiveAttributeIntercep { public boolean accept( SearchingOperationContext operation, ClonedServerEntry result ) throws Exception { - DN name = result.getDn(); - - if ( name.isNormalized() == false ) - { - name = DN.normalize( name, schemaManager.getNormalizerMapping() ); - } - String[] retAttrs = operation.getSearchControls().getReturningAttributes(); addCollectiveAttributes( operation, result, retAttrs ); + return true; } }; - - + //------------------------------------------------------------------------------------- + // Initialization + //------------------------------------------------------------------------------------- + /** + * {@inheritDoc} + */ public void init( DirectoryService directoryService ) throws LdapException { super.init( directoryService ); schemaManager = directoryService.getSchemaManager(); - nexus = directoryService.getPartitionNexus(); - collectiveAttributesSchemaChecker = new CollectiveAttributesSchemaChecker( nexus, schemaManager ); + // Load some AttributeType COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT = schemaManager.getAttributeType( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ); + COLLECTIVE_EXCLUSIONS_AT = schemaManager.getAttributeType( SchemaConstants.COLLECTIVE_EXCLUSIONS_AT ); + OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT ); + + LOG.debug( "CollectiveAttriute interceptor initilaized" ); + } + + + // ------------------------------------------------------------------------ + // Interceptor Method Overrides + // ------------------------------------------------------------------------ + /** + * {@inheritDoc} + */ + public void add( NextInterceptor next, AddOperationContext addContext ) throws LdapException + { + checkAdd( addContext.getDn(), addContext.getEntry() ); + + next.add( addContext ); + } + + + /** + * {@inheritDoc} + */ + public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext listContext ) + throws LdapException + { + EntryFilteringCursor cursor = nextInterceptor.list( listContext ); + + cursor.addEntryFilter( SEARCH_FILTER ); + + return cursor; + } + + + /** + * {@inheritDoc} + */ + public Entry lookup( NextInterceptor nextInterceptor, LookupOperationContext lookupContext ) throws LdapException + { + Entry result = nextInterceptor.lookup( lookupContext ); + + if ( result == null ) + { + return null; + } + + // Adding the collective attributes if any + if ( ( lookupContext.getAttrsId() == null ) || ( lookupContext.getAttrsId().size() == 0 ) ) + { + addCollectiveAttributes( lookupContext, result, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); + } + else + { + addCollectiveAttributes( lookupContext, result, lookupContext.getAttrsIdArray() ); + } + + return result; } /** + * {@inheritDoc} + */ + public void modify( NextInterceptor next, ModifyOperationContext modifyContext ) throws LdapException + { + checkModify( modifyContext ); + + next.modify( modifyContext ); + } + + + /** + * {@inheritDoc} + */ + public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext searchContext ) + throws LdapException + { + EntryFilteringCursor cursor = nextInterceptor.search( searchContext ); + + cursor.addEntryFilter( SEARCH_FILTER ); + + return cursor; + } + + + //------------------------------------------------------------------------------------- + // Helper methods + //------------------------------------------------------------------------------------- + /** + * Check if we can add an entry. There are two cases :
+ *
    + *
  • The entry is a normal entry : it should not contain any 'c-XXX' attributeType
  • + *
  • The entry is a collectiveAttributeSubentry + *
+ */ + private void checkAdd( DN normName, Entry entry ) throws LdapException + { + if ( entry.hasObjectClass( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRY_OC ) ) + { + // This is a collectiveAttribute subentry. It must have at least one collective + // attribute + for ( EntryAttribute attribute : entry ) + { + if ( attribute.getAttributeType().isCollective() ) + { + return; + } + } + + LOG.info( "A CollectiveAttribute subentry *should* have at least one collectiveAttribute" ); + throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_257_COLLECTIVE_SUBENTRY_WITHOUT_COLLECTIVE_AT ) ); + } + + if ( containsAnyCollectiveAttributes( entry ) ) + { + /* + * TODO: Replace the Exception and the ResultCodeEnum with the correct ones. + */ + LOG.info( "Cannot add the entry {} : it contains some CollectiveAttributes and is not a collective subentry", + entry ); + throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_241_CANNOT_STORE_COLLECTIVE_ATT_IN_ENTRY ) ); + } + } + + + /** + * Check that we can modify an entry + */ + private void checkModify( ModifyOperationContext modifyContext ) throws LdapException + { + List mods = modifyContext.getModItems(); + Entry originalEntry = modifyContext.getEntry(); + Entry targetEntry = ( Entry ) SchemaUtils.getTargetEntry( mods, originalEntry ); + + // If the modified entry contains the CollectiveAttributeSubentry, then the modification + // is accepted, no matter what + if ( targetEntry.contains( OBJECT_CLASS_AT, SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRY_OC ) ) + { + return; + } + + // Check that we don't add any collectve attribute, this is not allowed on normal entries + if ( hasCollectiveAttributes( mods ) ) + { + /* + * TODO: Replace the Exception and the ResultCodeEnum with the correct ones. + */ + LOG.info( "Cannot modify the entry {} : it contains some CollectiveAttributes and is not a collective subentry", + targetEntry ); + throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_242 ) ); + } + } + + + /** + * Check that we have a CollectiveAttribute in the modifications. (CollectiveAttributes + * are those with a name starting with 'c-'). + */ + private boolean hasCollectiveAttributes( List mods ) throws LdapException + { + for ( Modification mod : mods ) + { + // TODO: handle http://issues.apache.org/jira/browse/DIRSERVER-1198 + EntryAttribute attr = mod.getAttribute(); + AttributeType attrType = attr.getAttributeType(); + + // Defensive programming. Very unlikely to happen here... + if ( attrType == null ) + { + try + { + attrType = schemaManager.lookupAttributeTypeRegistry( attr.getUpId() ); + } + catch ( LdapException le ) + { + throw new LdapInvalidAttributeTypeException(); + } + } + + ModificationOperation modOp = mod.getOperation(); + + // If the AT is collective and we don't try to remove it, then we can return. + if ( attrType.isCollective() && ( modOp != ModificationOperation.REMOVE_ATTRIBUTE ) ) + { + return true; + } + } + + // No collective attrbute found + return false; + } + + + /** + * Check if the entry contains any collective AttributeType (those starting with 'c-') + */ + private boolean containsAnyCollectiveAttributes( Entry entry ) throws LdapException + { + Set attributeTypes = entry.getAttributeTypes(); + + for ( AttributeType attributeType : attributeTypes ) + { + if ( attributeType.isCollective() ) + { + return true; + } + } + + return false; + } + + + /** * Adds the set of collective attributes requested in the returning attribute list * and contained in subentries referenced by the entry. Excludes collective * attributes that are specified to be excluded via the 'collectiveExclusions' @@ -135,7 +356,7 @@ public class CollectiveAttributeIntercep * variance. */ EntryAttribute collectiveExclusions = ( ( ClonedServerEntry ) entry ).getOriginalEntry().get( - SchemaConstants.COLLECTIVE_EXCLUSIONS_AT ); + COLLECTIVE_EXCLUSIONS_AT ); Set exclusions = new HashSet(); if ( collectiveExclusions != null ) @@ -296,68 +517,4 @@ public class CollectiveAttributeIntercep return allSuperTypes; } - - - // ------------------------------------------------------------------------ - // Interceptor Method Overrides - // ------------------------------------------------------------------------ - - public Entry lookup( NextInterceptor nextInterceptor, LookupOperationContext lookupContext ) throws LdapException - { - Entry result = nextInterceptor.lookup( lookupContext ); - - if ( result == null ) - { - return null; - } - - if ( ( lookupContext.getAttrsId() == null ) || ( lookupContext.getAttrsId().size() == 0 ) ) - { - addCollectiveAttributes( lookupContext, result, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY ); - } - else - { - addCollectiveAttributes( lookupContext, result, lookupContext.getAttrsIdArray() ); - } - - return result; - } - - - public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext listContext ) - throws LdapException - { - EntryFilteringCursor cursor = nextInterceptor.list( listContext ); - cursor.addEntryFilter( SEARCH_FILTER ); - return cursor; - } - - - public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext searchContext ) - throws LdapException - { - EntryFilteringCursor cursor = nextInterceptor.search( searchContext ); - cursor.addEntryFilter( SEARCH_FILTER ); - return cursor; - } - - - // ------------------------------------------------------------------------ - // Partial Schema Checking - // ------------------------------------------------------------------------ - - public void add( NextInterceptor next, AddOperationContext addContext ) throws LdapException - { - collectiveAttributesSchemaChecker.checkAdd( addContext.getDn(), addContext.getEntry() ); - - next.add( addContext ); - } - - - public void modify( NextInterceptor next, ModifyOperationContext modifyContext ) throws LdapException - { - collectiveAttributesSchemaChecker.checkModify( modifyContext ); - - next.modify( modifyContext ); - } } Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java Tue Jul 20 01:08:19 2010 @@ -20,8 +20,6 @@ package org.apache.directory.server.core.subtree; -import java.util.Iterator; - import org.apache.directory.server.core.event.Evaluator; import org.apache.directory.server.core.event.ExpressionEvaluator; import org.apache.directory.shared.ldap.entry.Entry; @@ -29,7 +27,6 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.name.DN; import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.subtree.SubtreeSpecification; -import org.apache.directory.shared.ldap.util.NamespaceTools; /** @@ -79,51 +76,16 @@ public class SubtreeEvaluator * specification. * ===================================================================== */ - - /* - * First we simply check if the candidate entry is a descendant of the - * administrative point. In the process we calculate the relative - * distinguished name relative to the administrative point. - */ - DN apRelativeRdn; + // First construct the subtree base, which is the concatenation of the + // AP DN and the subentry base + DN subentryBaseDn = (DN)apDn.clone(); + subentryBaseDn.addAll( subtree.getBase() ); - if ( !entryDn.isChildOf( apDn ) ) + if ( !entryDn.isChildOf( subentryBaseDn ) ) { + // The entry DN is not part of the subtree specification, get out return false; } - else if ( apDn.equals( entryDn ) ) - { - apRelativeRdn = new DN(); - } - else - { - apRelativeRdn = NamespaceTools.getRelativeName( apDn, entryDn ); - } - - /* - * We do the same thing with the base as we did with the administrative - * point: check if the entry is a descendant of the base and find the - * relative name of the entry with respect to the base rdn. With the - * baseRelativeRdn we can later make comparisons with specific exclusions. - */ - DN baseRelativeRdn; - - if ( subtree.getBase() != null && subtree.getBase().size() == 0 ) - { - baseRelativeRdn = apRelativeRdn; - } - else if ( apRelativeRdn.equals( subtree.getBase() ) ) - { - baseRelativeRdn = new DN(); - } - else if ( !apRelativeRdn.isChildOf( subtree.getBase() ) ) - { - return false; - } - else - { - baseRelativeRdn = NamespaceTools.getRelativeName( subtree.getBase(), apRelativeRdn ); - } /* * Evaluate based on minimum and maximum chop values. Here we simply @@ -133,13 +95,15 @@ public class SubtreeEvaluator * entries with a baseRelativeRdn size less than the minimum distance * are rejected. */ - if ( subtree.getMaxBaseDistance() != SubtreeSpecification.UNBOUNDED_MAX && - subtree.getMaxBaseDistance() < baseRelativeRdn.size() ) + int entryRelativeDnSize = entryDn.size() - subentryBaseDn.size(); + + if ( ( subtree.getMaxBaseDistance() != SubtreeSpecification.UNBOUNDED_MAX ) && + ( entryRelativeDnSize > subtree.getMaxBaseDistance() ) ) { return false; } - if ( subtree.getMinBaseDistance() > 0 && baseRelativeRdn.size() < subtree.getMinBaseDistance() ) + if ( ( subtree.getMinBaseDistance() > 0 ) && ( entryRelativeDnSize < subtree.getMinBaseDistance() ) ) { return false; } @@ -151,27 +115,27 @@ public class SubtreeEvaluator * are equal so for chopAfter exclusions we must check for equality * as well and reject if the relative names are equal. */ - Iterator list = subtree.getChopBeforeExclusions().iterator(); + // Now, get the entry's relative part - while ( list.hasNext() ) + if ( ( subtree.getChopBeforeExclusions().size() != 0 ) || + ( subtree.getChopAfterExclusions().size() != 0 ) ) { - DN chopBefore = list.next(); + DN entryRelativeDn = entryDn.getSuffix( apDn.size() + subtree.getBase().size() ); - if ( baseRelativeRdn.isChildOf( chopBefore ) ) + for ( DN chopBeforeDn : subtree.getChopBeforeExclusions() ) { - return false; + if ( entryRelativeDn.isChildOf( chopBeforeDn ) ) + { + return false; + } } - } - - list = subtree.getChopAfterExclusions().iterator(); - - while ( list.hasNext() ) - { - DN chopAfter = ( DN ) list.next(); - - if ( baseRelativeRdn.isChildOf( chopAfter ) && !chopAfter.equals( baseRelativeRdn ) ) + + for ( DN chopAfterDn : subtree.getChopAfterExclusions() ) { - return false; + if ( entryRelativeDn.isChildOf( chopAfterDn ) && !chopAfterDn.equals( entryRelativeDn ) ) + { + return false; + } } } Modified: directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java (original) +++ directory/apacheds/trunk/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java Tue Jul 20 01:08:19 2010 @@ -274,7 +274,7 @@ public enum I18n ERR_238("ERR_238"), ERR_239("ERR_239"), ERR_240("ERR_240"), - ERR_241("ERR_241"), + ERR_241_CANNOT_STORE_COLLECTIVE_ATT_IN_ENTRY("ERR_241_CANNOT_STORE_COLLECTIVE_ATT_IN_ENTRY"), ERR_242("ERR_242"), ERR_243("ERR_243"), ERR_244("ERR_244"), @@ -290,7 +290,7 @@ public enum I18n ERR_254_ADD_EXISTING_VALUE("ERR_254_ADD_EXISTING_VALUE"), ERR_255("ERR_255"), ERR_256_NO_SUCH_OBJECT("ERR_256_NO_SUCH_OBJECT"), - //ERR_257("ERR_257"), --> ERR_250 + ERR_257_COLLECTIVE_SUBENTRY_WITHOUT_COLLECTIVE_AT("ERR_257_COLLECTIVE_SUBENTRY_WITHOUT_COLLECTIVE_AT"), ERR_258("ERR_258"), ERR_259("ERR_259"), ERR_260("ERR_260"), @@ -768,8 +768,8 @@ public enum I18n ERR_732("ERR_732"), ERR_733("ERR_733"); - private final static ResourceBundle errBundle = ResourceBundle - .getBundle( "org/apache/directory/server/i18n/errors" ); + private static ResourceBundle errBundle = ResourceBundle + .getBundle( "org.apache.directory.server.i18n.errors" ); private final static ResourceBundle msgBundle = ResourceBundle .getBundle( "org/apache/directory/server/i18n/messages" ); Modified: directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties (original) +++ directory/apacheds/trunk/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties Tue Jul 20 01:08:19 2010 @@ -262,7 +262,7 @@ ERR_237=The underlying changelog store d ERR_238=The underlying changelog store does not support searching through it's tags ERR_239=revision must be greater than or equal to 0 ERR_240=revision must be less than or equal to the current revision -ERR_241=Collective attributes cannot be stored in non-collectiveAttributeSubentries +ERR_241_CANNOT_STORE_COLLECTIVE_ATT_IN_ENTRY=Collective attributes cannot be stored in non-collectiveAttributeSubentries ERR_242=Cannot operate on collective attributes in non-collectiveAttributeSubentries ERR_243=Negation has no child: {0} ERR_244=Unrecognized branch node operator: {0} @@ -278,7 +278,7 @@ ERR_253=Can not allow the deletion of th ERR_254_ADD_EXISTING_VALUE=Trying to add existing value ''{0}'' to attribute {1} ERR_255=Can not allow the renaming of the subschemaSubentry ({0}) for the global schema: it is fixed at {1} ERR_256_NO_SUCH_OBJECT=Entry {0} does not exist! -#ERR_257=Entry {0} already exists! +ERR_257_COLLECTIVE_SUBENTRY_WITHOUT_COLLECTIVE_AT=A CollectiveAttribute Subentry must have at least one collective Attribute ERR_258=Can not allow the move of the subschemaSubentry ({0}) for the global schema\: it is fixed at {1} ERR_259=Attempt to search under non-existant entry\: ERR_260=Unknown assertion type: {0} Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,4 +1,5 @@ /directory/apacheds/branches/apacheds-replication/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:749790-764110 /directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:806623-810034 +/directory/apacheds/branches/apacheds-subtree/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:965203-965686 /directory/apacheds/branches/xdbm-refactoring/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:945827-946347 /directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:498338-580500,806623-894866* Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,3 +1,4 @@ /directory/apacheds/branches/apacheds-replication/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:749790-764110 +/directory/apacheds/branches/apacheds-subtree/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:965203-965686 /directory/apacheds/branches/xdbm-refactoring/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:945827-946347 /directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:498338-580500,806623-894866 Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,4 +1,5 @@ /directory/apacheds/branches/apacheds-replication/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:749790-764110 /directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:806623-810034 +/directory/apacheds/branches/apacheds-subtree/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:965203-965686 /directory/apacheds/branches/xdbm-refactoring/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:945827-946347 /directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:498338-580500,806623-894866* Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,4 +1,5 @@ /directory/apacheds/branches/apacheds-replication/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:749790-764110 /directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:806623-810034 +/directory/apacheds/branches/apacheds-subtree/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:965203-965686 /directory/apacheds/branches/xdbm-refactoring/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:945827-946347 /directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:498338-580500,806623-894866 Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java (original) +++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java Tue Jul 20 01:08:19 2010 @@ -42,6 +42,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.integ.FrameworkRunner; import org.apache.directory.shared.ldap.cursor.Cursor; import org.apache.directory.shared.ldap.entry.Entry; +import org.apache.directory.shared.ldap.exception.LdapException; import org.apache.directory.shared.ldap.filter.SearchScope; import org.apache.directory.shared.ldap.message.AliasDerefMode; import org.apache.directory.shared.ldap.message.ResultCodeEnum; @@ -70,14 +71,22 @@ import org.junit.runner.RunWith; "objectClass: top", "sn: user1 sn", "cn: user1", - + // alias to the above entry "dn: cn=user1-alias,ou=users,ou=system", "objectClass: alias", "objectClass: top", "objectClass: extensibleObject", "aliasedObjectName: cn=user1,ou=users,ou=system", - "cn: user1-alias" + "cn: user1-alias", + + // Another user + "dn: cn=elecharny,ou=users,ou=system", + "objectClass: person", + "objectClass: top", + "sn:: RW1tYW51ZWwgTMOpY2hhcm55", + "cn: elecharny" + }) public class ClientSearchRequestTest extends AbstractLdapTestUnit { @@ -155,6 +164,7 @@ public class ClientSearchRequestTest ext "+" ); int count = 0; SearchResponse searchResponse = null; + do { searchResponse = ( SearchResponse ) searchFuture.get( 1000, TimeUnit.MILLISECONDS ); @@ -181,6 +191,7 @@ public class ClientSearchRequestTest ext "+" ); int count = 0; SearchResponse searchResponse = null; + do { searchResponse = ( SearchResponse ) searchFuture.get( 100000, TimeUnit.MILLISECONDS ); @@ -193,7 +204,7 @@ public class ClientSearchRequestTest ext } while ( !( searchResponse instanceof SearchResultDone ) ); - assertEquals(2, count ); + assertEquals( 3, count ); } @@ -208,22 +219,32 @@ public class ClientSearchRequestTest ext int count = 0; Cursor cursor = connection.search( searchRequest ); + while( cursor.next() ) { count++; } // due to dereferencing of aliases we get only one entry - assertEquals( 1, count ); + assertEquals( 2, count ); count = 0; searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES ); cursor = connection.search( searchRequest ); + while( cursor.next() ) { count++; } - assertEquals( 2, count ); + assertEquals( 3, count ); + } + + + @Test(expected=LdapException.class) + public void testSearchUTF8() throws Exception + { + connection.search( "ou=system", "(sn=Emmanuel LŽcharny)", SearchScope.ONELEVEL, "*", "+" ); + fail(); } } Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java?rev=965704&r1=965703&r2=965704&view=diff ============================================================================== --- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java (original) +++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java Tue Jul 20 01:08:19 2010 @@ -41,7 +41,6 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.name.DN; import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; Propchange: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,3 +1,4 @@ /directory/apacheds/branches/apacheds-replication/syncrepl/src/main/java/org/apache/directory/server/syncrepl/SyncReplConsumer.java:749790-764110 /directory/apacheds/branches/apacheds-schema/syncrepl/src/main/java/org/apache/directory/server/syncrepl/SyncReplConsumer.java:806623-896441 +/directory/apacheds/branches/apacheds-subtree/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java:965203-965686 /directory/apacheds/branches/xdbm-refactoring/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java:945827-946347 Propchange: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,3 +1,4 @@ /directory/apacheds/branches/apacheds-replication/core-annotations/src/main/java/org/apache/directory/server/core/factory/ConfigPartitionReader.java:749790-764110 /directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/ConfigPartitionReader.java:806623-896441 +/directory/apacheds/branches/apacheds-subtree/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java:965203-965686 /directory/apacheds/branches/xdbm-refactoring/default-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java:945827-946347 Propchange: directory/apacheds/trunk/server-config/src/main/resources/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -3,4 +3,5 @@ /directory/apacheds/branches/apacheds-replication/default-config/src/main/resources:749790-764110 /directory/apacheds/branches/apacheds-schema/core-annotations/src/main/resources:806623-896441 /directory/apacheds/branches/apacheds-schema/default-config/src/main/resources:806623-896441 +/directory/apacheds/branches/apacheds-subtree/server-config/src/main/resources:965203-965686 /directory/apacheds/branches/xdbm-refactoring/default-config/src/main/resources:945827-946347 Propchange: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,4 +1,5 @@ /directory/apacheds/branches/apacheds-replication/core-annotations/src/main/java/org/apache/directory/server/core/factory/CiDITDirectoryServiceFactory.java:749790-764110 /directory/apacheds/branches/apacheds-schema/core-annotations/src/main/java/org/apache/directory/server/core/factory/CiDITDirectoryServiceFactory.java:806623-896441 +/directory/apacheds/branches/apacheds-subtree/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java:965203-965686 /directory/apacheds/branches/cidit/default-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java:900288-900681 /directory/apacheds/branches/xdbm-refactoring/default-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java:945827-946347 Propchange: directory/apacheds/trunk/test-framework/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Jul 20 01:08:19 2010 @@ -1,4 +1,5 @@ /directory/apacheds/branches/apacheds-replication/apacheds-test-framework:749790-764110 /directory/apacheds/branches/apacheds-replication/test-framework:749790-764110 /directory/apacheds/branches/apacheds-schema/test-framework:806623-896441 +/directory/apacheds/branches/apacheds-subtree/test-framework:965203-965686 /directory/apacheds/branches/xdbm-refactoring/test-framework:945827-946347