Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 8522 invoked from network); 14 Jun 2006 03:23:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Jun 2006 03:23:22 -0000 Received: (qmail 49704 invoked by uid 500); 14 Jun 2006 03:23:21 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 49633 invoked by uid 500); 14 Jun 2006 03:23:21 -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 49621 invoked by uid 99); 14 Jun 2006 03:23:21 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 20:23:21 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 20:23:17 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 5EC9E1A9859; Tue, 13 Jun 2006 20:22:32 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r414035 [6/8] - in /directory/trunks/apacheds: ./ core-plugin/ core-shared/ core-unit/ core-unit/src/main/java/org/apache/directory/server/core/unit/ core-unit/src/test/java/org/apache/directory/server/core/ core-unit/src/test/java/org/apac... Date: Wed, 14 Jun 2006 03:22:12 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060614032232.5EC9E1A9859@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java Tue Jun 13 20:22:05 2006 @@ -27,7 +27,6 @@ import java.util.Map; import javax.naming.Context; -import javax.naming.Name; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.Attribute; @@ -38,6 +37,7 @@ import javax.naming.directory.SearchResult; import org.apache.directory.server.core.DirectoryServiceConfiguration; +import org.apache.directory.server.core.ServerUtils; import org.apache.directory.server.core.configuration.DirectoryPartitionConfiguration; import org.apache.directory.server.core.configuration.InterceptorConfiguration; import org.apache.directory.server.core.enumeration.ReferralHandlingEnumeration; @@ -52,7 +52,8 @@ import org.apache.directory.server.core.partition.DirectoryPartitionNexus; import org.apache.directory.server.core.partition.DirectoryPartitionNexusProxy; import org.apache.directory.server.core.schema.AttributeTypeRegistry; -import org.apache.directory.server.core.schema.ConcreteNameComponentNormalizer; +import org.apache.directory.server.core.schema.OidRegistry; + import org.apache.directory.shared.ldap.codec.util.LdapURL; import org.apache.directory.shared.ldap.NotImplementedException; import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException; @@ -62,8 +63,8 @@ import org.apache.directory.shared.ldap.filter.LeafNode; import org.apache.directory.shared.ldap.filter.SimpleNode; import org.apache.directory.shared.ldap.message.ResultCodeEnum; -import org.apache.directory.shared.ldap.name.DnParser; -import org.apache.directory.shared.ldap.name.LdapName; +import org.apache.directory.shared.ldap.name.LdapDN; +import org.apache.directory.shared.ldap.schema.AttributeType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,9 +93,11 @@ private ReferralLut lut = new ReferralLut(); private DirectoryPartitionNexus nexus; - private DnParser parser; private Hashtable env; + private AttributeTypeRegistry attrRegistry; + private OidRegistry oidRegistry; + static { /* @@ -158,20 +161,20 @@ public void init( DirectoryServiceConfiguration dsConfig, InterceptorConfiguration cfg ) throws NamingException { nexus = dsConfig.getPartitionNexus(); - AttributeTypeRegistry atr = dsConfig.getGlobalRegistries().getAttributeTypeRegistry(); - parser = new DnParser( new ConcreteNameComponentNormalizer( atr ) ); + attrRegistry = dsConfig.getGlobalRegistries().getAttributeTypeRegistry(); + oidRegistry = dsConfig.getGlobalRegistries().getOidRegistry(); env = dsConfig.getEnvironment(); - Iterator suffixes = nexus.listSuffixes( true ); + Iterator suffixes = nexus.listSuffixes(); while ( suffixes.hasNext() ) { - Name suffix = new LdapName( ( String ) suffixes.next() ); + LdapDN suffix = new LdapDN( ( String ) suffixes.next() ); addReferrals( nexus.search( suffix, env, getReferralFilter(), getControls() ), suffix ); } } - public void doReferralException( Name farthest, Name targetUpdn, Attribute refs ) throws NamingException + public void doReferralException( LdapDN farthest, LdapDN targetUpdn, Attribute refs ) throws NamingException { // handle referral here List list = new ArrayList( refs.size() ); @@ -197,7 +200,8 @@ log.error( "Bad URL (" + val + ") for ref in " + farthest + ". Reference will be ignored." ); } - Name urlDn = parser.parse( ldapUrl.getDn().toString() ); + LdapDN urlDn = new LdapDN( ldapUrl.getDn().toNormName() ); + urlDn.normalize(); if ( urlDn.equals( farthest ) ) { // according to the protocol there is no need for the dn since it is the same as this request @@ -220,7 +224,7 @@ * name past the farthest referral DN which the target name extends. */ int diff = targetUpdn.size() - farthest.size(); - Name extra = new LdapName(); + LdapDN extra = new LdapDN(); for ( int jj = 0; jj < diff; jj++ ) { extra.add( targetUpdn.get( farthest.size() + jj ) ); @@ -236,7 +240,7 @@ buf.append( ldapUrl.getPort() ); } buf.append( "/" ); - buf.append( urlDn ); + buf.append( urlDn.toUpName() ); list.add( buf.toString() ); } LdapReferralException lre = new LdapReferralException( list ); @@ -244,7 +248,7 @@ } - public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException + public void add(NextInterceptor next, LdapDN normName, Attributes entry) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); @@ -253,7 +257,7 @@ // handle a normal add without following referrals if ( refval == null || refval.equals( IGNORE ) ) { - next.add( upName, normName, entry ); + next.add(normName, entry ); if ( isReferral( entry ) ) { lut.referralAdded( normName ); @@ -263,10 +267,10 @@ if ( refval.equals( THROW ) ) { - Name farthest = lut.getFarthestReferralAncestor( normName ); + LdapDN farthest = lut.getFarthestReferralAncestor( normName ); if ( farthest == null ) { - next.add( upName, normName, entry ); + next.add(normName, entry ); if ( isReferral( entry ) ) { lut.referralAdded( normName ); @@ -275,8 +279,9 @@ } Attributes referral = invocation.getProxy().lookup( farthest, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); - Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthest, new LdapName( upName ), refs ); + AttributeType refsType = attrRegistry.lookup( oidRegistry.getOid( REF_ATTR ) ); + Attribute refs = ServerUtils.getAttribute( refsType, referral ); + doReferralException( farthest, new LdapDN( normName.toUpName() ), refs ); } else if ( refval.equals( FOLLOW ) ) { @@ -290,7 +295,7 @@ } - public boolean compare( NextInterceptor next, Name normName, String oid, Object value ) throws NamingException + public boolean compare( NextInterceptor next, LdapDN normName, String oid, Object value ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); @@ -304,7 +309,7 @@ if ( refval.equals( THROW ) ) { - Name farthest = lut.getFarthestReferralAncestor( normName ); + LdapDN farthest = lut.getFarthestReferralAncestor( normName ); if ( farthest == null ) { return next.compare( normName, oid, value ); @@ -312,7 +317,7 @@ Attributes referral = invocation.getProxy().lookup( farthest, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthest, normName, refs ); + doReferralException( farthest, new LdapDN( normName.toUpName() ), refs ); // we really can't get here since doReferralException will throw an exception return false; @@ -329,7 +334,7 @@ } - public void delete( NextInterceptor next, Name normName ) throws NamingException + public void delete( NextInterceptor next, LdapDN normName ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); @@ -348,7 +353,7 @@ if ( refval.equals( THROW ) ) { - Name farthest = lut.getFarthestReferralAncestor( normName ); + LdapDN farthest = lut.getFarthestReferralAncestor( normName ); if ( farthest == null ) { next.delete( normName ); @@ -361,7 +366,7 @@ Attributes referral = invocation.getProxy().lookup( farthest, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthest, normName, refs ); + doReferralException( farthest, new LdapDN( normName.toUpName() ), refs ); } else if ( refval.equals( FOLLOW ) ) { @@ -390,12 +395,12 @@ * ----------------------------------------------------------------------- */ - public void move( NextInterceptor next, Name oldName, Name newParent ) throws NamingException + public void move( NextInterceptor next, LdapDN oldName, LdapDN newParent ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); - Name newName = ( Name ) newParent.clone(); + LdapDN newName = ( LdapDN ) newParent.clone(); newName.add( oldName.get( oldName.size() - 1 ) ); // handle a normal modify without following referrals @@ -411,8 +416,8 @@ if ( refval.equals( THROW ) ) { - Name farthestSrc = lut.getFarthestReferralAncestor( oldName ); - Name farthestDst = lut.getFarthestReferralAncestor( newName ); // note will not return newName so safe + LdapDN farthestSrc = lut.getFarthestReferralAncestor( oldName ); + LdapDN farthestDst = lut.getFarthestReferralAncestor( newName ); // note will not return newName so safe if ( farthestSrc == null && farthestDst == null && !lut.isReferral( newName ) ) { next.move( oldName, newParent ); @@ -427,7 +432,7 @@ Attributes referral = invocation.getProxy().lookup( farthestSrc, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthestSrc, oldName, refs ); + doReferralException( farthestSrc, new LdapDN( oldName.toUpName() ), refs ); } else if ( farthestDst != null ) { @@ -456,13 +461,13 @@ } - public void move( NextInterceptor next, Name oldName, Name newParent, String newRdn, boolean deleteOldRdn ) + public void move( NextInterceptor next, LdapDN oldName, LdapDN newParent, String newRdn, boolean deleteOldRdn ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); - Name newName = ( Name ) newParent.clone(); + LdapDN newName = ( LdapDN ) newParent.clone(); newName.add( newRdn ); // handle a normal modify without following referrals @@ -478,8 +483,8 @@ if ( refval.equals( THROW ) ) { - Name farthestSrc = lut.getFarthestReferralAncestor( oldName ); - Name farthestDst = lut.getFarthestReferralAncestor( newName ); // safe to use - does not return newName + LdapDN farthestSrc = lut.getFarthestReferralAncestor( oldName ); + LdapDN farthestDst = lut.getFarthestReferralAncestor( newName ); // safe to use - does not return newName if ( farthestSrc == null && farthestDst == null && !lut.isReferral( newName ) ) { next.move( oldName, newParent, newRdn, deleteOldRdn ); @@ -494,7 +499,7 @@ Attributes referral = invocation.getProxy().lookup( farthestSrc, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthestSrc, oldName, refs ); + doReferralException( farthestSrc, new LdapDN( oldName.toUpName() ), refs ); } else if ( farthestDst != null ) { @@ -523,15 +528,18 @@ } - public void modifyRn( NextInterceptor next, Name oldName, String newRdn, boolean deleteOldRdn ) + public void modifyRn( NextInterceptor next, LdapDN oldName, String newRdn, boolean deleteOldRdn ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); String refval = ( String ) caller.getEnvironment().get( Context.REFERRAL ); - Name newName = ( Name ) oldName.clone(); + LdapDN newName = ( LdapDN ) oldName.clone(); newName.remove( oldName.size() - 1 ); - newName.add( parser.parse( newRdn ).toString() ); + + LdapDN newRdnName = new LdapDN( newRdn ); + newRdnName.normalize(); + newName.add( newRdnName.toNormName() ); // handle a normal modify without following referrals if ( refval == null || refval.equals( IGNORE ) ) @@ -546,8 +554,8 @@ if ( refval.equals( THROW ) ) { - Name farthestSrc = lut.getFarthestReferralAncestor( oldName ); - Name farthestDst = lut.getFarthestReferralAncestor( newName ); + LdapDN farthestSrc = lut.getFarthestReferralAncestor( oldName ); + LdapDN farthestDst = lut.getFarthestReferralAncestor( newName ); if ( farthestSrc == null && farthestDst == null && !lut.isReferral( newName ) ) { next.modifyRn( oldName, newRdn, deleteOldRdn ); @@ -562,7 +570,7 @@ Attributes referral = invocation.getProxy().lookup( farthestSrc, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthestSrc, oldName, refs ); + doReferralException( farthestSrc, new LdapDN( oldName.toUpName() ), refs ); } else if ( farthestDst != null ) { @@ -591,7 +599,7 @@ } - private void checkModify( Name name, int modOp, Attributes mods ) throws NamingException + private void checkModify( LdapDN name, int modOp, Attributes mods ) throws NamingException { // ------------------------------------------------------------------- // Check and update lut if we change the objectClass @@ -649,7 +657,7 @@ } - public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException + public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes mods ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); @@ -665,7 +673,7 @@ if ( refval.equals( THROW ) ) { - Name farthest = lut.getFarthestReferralAncestor( name ); + LdapDN farthest = lut.getFarthestReferralAncestor( name ); if ( farthest == null ) { next.modify( name, modOp, mods ); @@ -675,7 +683,7 @@ Attributes referral = invocation.getProxy().lookup( farthest, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthest, name, refs ); + doReferralException( farthest, new LdapDN( name.toUpName() ), refs ); } else if ( refval.equals( FOLLOW ) ) { @@ -689,7 +697,7 @@ } - private void checkModify( Name name, ModificationItem[] mods ) throws NamingException + private void checkModify( LdapDN name, ModificationItem[] mods ) throws NamingException { boolean isTargetReferral = lut.isReferral( name ); @@ -753,7 +761,7 @@ } - public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException + public void modify( NextInterceptor next, LdapDN name, ModificationItem[] mods ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); ServerLdapContext caller = ( ServerLdapContext ) invocation.getCaller(); @@ -769,7 +777,7 @@ if ( refval.equals( THROW ) ) { - Name farthest = lut.getFarthestReferralAncestor( name ); + LdapDN farthest = lut.getFarthestReferralAncestor( name ); if ( farthest == null ) { next.modify( name, mods ); @@ -779,7 +787,7 @@ Attributes referral = invocation.getProxy().lookup( farthest, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralException( farthest, name, refs ); + doReferralException( farthest, new LdapDN( name.toUpName() ), refs ); } else if ( refval.equals( FOLLOW ) ) { @@ -814,7 +822,7 @@ // add referrals immediately after adding the new partition DirectoryPartition partition = cfg.getContextPartition(); - Name suffix = partition.getSuffix( true ); + LdapDN suffix = partition.getSuffix(); Invocation invocation = InvocationStack.getInstance().peek(); NamingEnumeration list = invocation.getProxy().search( suffix, env, getReferralFilter(), getControls(), SEARCH_BYPASS ); @@ -822,7 +830,7 @@ } - public void removeContextPartition( NextInterceptor next, Name suffix ) throws NamingException + public void removeContextPartition( NextInterceptor next, LdapDN suffix ) throws NamingException { // remove referrals immediately before removing the partition Invocation invocation = InvocationStack.getInstance().peek(); @@ -834,45 +842,52 @@ } - private void addReferrals( NamingEnumeration referrals, Name base ) throws NamingException + private void addReferrals( NamingEnumeration referrals, LdapDN base ) throws NamingException { while ( referrals.hasMore() ) { SearchResult r = ( SearchResult ) referrals.next(); - Name referral = null; + LdapDN referral = null; + LdapDN result = new LdapDN( r.getName() ); + //result = LdapDN.normalize( result, registry.getNormalizerMapping() ); + result.normalize(); + if ( r.isRelative() ) { - referral = ( Name ) base.clone(); - referral.addAll( parser.parse( r.getName() ) ); + referral = ( LdapDN ) base.clone(); + referral.addAll( result ); } else { - referral = parser.parse( r.getName() ); + referral = result; } } } - private void deleteReferrals( NamingEnumeration referrals, Name base ) throws NamingException + private void deleteReferrals( NamingEnumeration referrals, LdapDN base ) throws NamingException { while ( referrals.hasMore() ) { SearchResult r = ( SearchResult ) referrals.next(); - Name referral = null; + LdapDN referral = null; + LdapDN result = new LdapDN( r.getName() ); + result.normalize(); + if ( r.isRelative() ) { - referral = ( Name ) base.clone(); - referral.addAll( parser.parse( r.getName() ) ); + referral = ( LdapDN ) base.clone(); + referral.addAll( result ); } else { - referral = parser.parse( r.getName() ); + referral = result; } } } - public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls controls ) + public NamingEnumeration search( NextInterceptor next, LdapDN base, Map env, ExprNode filter, SearchControls controls ) throws NamingException { Invocation invocation = InvocationStack.getInstance().peek(); @@ -899,7 +914,7 @@ doReferralExceptionOnSearchBase( base, refs, controls.getSearchScope() ); } - Name farthest = lut.getFarthestReferralAncestor( base ); + LdapDN farthest = lut.getFarthestReferralAncestor( base ); if ( farthest == null ) { return next.search( base, env, filter, controls ); @@ -907,7 +922,7 @@ Attributes referral = invocation.getProxy().lookup( farthest, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralExceptionOnSearchBase( farthest, base, refs, controls.getSearchScope() ); + doReferralExceptionOnSearchBase( farthest, new LdapDN( base.toUpName() ), refs, controls.getSearchScope() ); throw new IllegalStateException( "Should never get here: shutting up compiler" ); } if ( refval.equals( THROW ) ) @@ -919,17 +934,17 @@ doReferralExceptionOnSearchBase( base, refs, controls.getSearchScope() ); } - Name farthest = lut.getFarthestReferralAncestor( base ); + LdapDN farthest = lut.getFarthestReferralAncestor( base ); if ( farthest == null ) { SearchResultFilteringEnumeration srfe = ( SearchResultFilteringEnumeration ) next.search( base, env, filter, controls ); - return new ReferralHandlingEnumeration( srfe, lut, parser, nexus, controls.getSearchScope(), true ); + return new ReferralHandlingEnumeration( srfe, lut, attrRegistry, nexus, controls.getSearchScope(), true ); } Attributes referral = invocation.getProxy().lookup( farthest, DirectoryPartitionNexusProxy.LOOKUP_BYPASS ); Attribute refs = referral.get( REF_ATTR ); - doReferralExceptionOnSearchBase( farthest, base, refs, controls.getSearchScope() ); + doReferralExceptionOnSearchBase( farthest, new LdapDN( base.toUpName() ), refs, controls.getSearchScope() ); throw new IllegalStateException( "Should never get here: shutting up compiler" ); } else if ( refval.equals( FOLLOW ) ) @@ -953,7 +968,7 @@ } - public void doReferralExceptionOnSearchBase( Name base, Attribute refs, int scope ) throws NamingException + public void doReferralExceptionOnSearchBase( LdapDN base, Attribute refs, int scope ) throws NamingException { // handle referral here List list = new ArrayList( refs.size() ); @@ -1013,7 +1028,7 @@ } - public void doReferralExceptionOnSearchBase( Name farthest, Name targetUpdn, Attribute refs, int scope ) + public void doReferralExceptionOnSearchBase( LdapDN farthest, LdapDN targetUpdn, Attribute refs, int scope ) throws NamingException { // handle referral here @@ -1040,9 +1055,10 @@ log.error( "Bad URL (" + val + ") for ref in " + farthest + ". Reference will be ignored." ); } - Name urlDn = parser.parse( ldapUrl.getDn().toString() ); + LdapDN urlDn = new LdapDN( ldapUrl.getDn().toNormName() ); + urlDn.normalize(); int diff = targetUpdn.size() - farthest.size(); - Name extra = new LdapName(); + LdapDN extra = new LdapDN(); for ( int jj = 0; jj < diff; jj++ ) { extra.add( targetUpdn.get( farthest.size() + jj ) ); @@ -1058,7 +1074,7 @@ buf.append( ldapUrl.getPort() ); } buf.append( "/" ); - buf.append( urlDn ); + buf.append( urlDn.toUpName() ); buf.append( "??" ); switch ( scope ) @@ -1089,7 +1105,10 @@ return true; } - if ( lut.isReferral( parser.parse( name ) ) ) + LdapDN dn = new LdapDN( name ); + dn.normalize(); + + if ( lut.isReferral( dn ) ) { return true; } Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/AttributeTypeRegistry.java Tue Jun 13 20:22:05 2006 @@ -18,6 +18,7 @@ import java.util.Iterator; +import java.util.Map; import javax.naming.NamingException; @@ -80,4 +81,11 @@ * @return an iterator over all AttributeTypes in registry */ Iterator list(); + + + /** + * Gets an oid/name to normalizer mapping used to normalize distinguished + * names. + */ + Map getNormalizerMapping() throws NamingException; } Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java Tue Jun 13 20:22:05 2006 @@ -35,7 +35,9 @@ public class ConcreteNameComponentNormalizer implements NameComponentNormalizer { /** the at registry used to dynamically resolve Normalizers */ - private final AttributeTypeRegistry registry; + private final AttributeTypeRegistry attributeRegistry; + /** the oid registry used to dynamically resolve aliases to OIDs */ + private final OidRegistry oidRegistry; /** @@ -45,9 +47,10 @@ * * @param registry the at registry used to dynamically resolve Normalizers */ - public ConcreteNameComponentNormalizer(AttributeTypeRegistry registry) + public ConcreteNameComponentNormalizer( AttributeTypeRegistry registry, OidRegistry oidRegistry ) { - this.registry = registry; + this.attributeRegistry = registry; + this.oidRegistry = oidRegistry; } @@ -100,7 +103,7 @@ */ private Normalizer lookup( String id ) throws NamingException { - AttributeType type = registry.lookup( id ); + AttributeType type = attributeRegistry.lookup( id ); return type.getEquality().getNormalizer(); } @@ -110,6 +113,12 @@ */ public boolean isDefined( String id ) { - return registry.hasAttributeType( id ); + return attributeRegistry.hasAttributeType( id ); + } + + + public String normalizeName( String attributeName ) throws NamingException + { + return oidRegistry.getOid( attributeName ); } } Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java Tue Jun 13 20:22:05 2006 @@ -477,7 +477,8 @@ * @param attribute the attribute being modified * @throws NamingException if the modify operation is removing an Rdn attribute */ - public static void preventRdnChangeOnModifyRemove( Name name, int mod, Attribute attribute ) throws NamingException + public static void preventRdnChangeOnModifyRemove( Name name, int mod, Attribute attribute, + OidRegistry oidRegistry ) throws NamingException { if ( mod != DirContext.REMOVE_ATTRIBUTE ) { @@ -487,7 +488,7 @@ Set rdnAttributes = getRdnAttributes( name ); String id = attribute.getID(); - if ( !rdnAttributes.contains( id ) ) + if ( !rdnAttributes.contains( oidRegistry.getOid( id ) ) ) { return; } Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Tue Jun 13 20:22:05 2006 @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Set; -import javax.naming.Name; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.*; @@ -50,7 +49,7 @@ import org.apache.directory.shared.ldap.message.LockableAttributeImpl; import org.apache.directory.shared.ldap.message.LockableAttributesImpl; import org.apache.directory.shared.ldap.message.ResultCodeEnum; -import org.apache.directory.shared.ldap.name.LdapName; +import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.DITContentRule; import org.apache.directory.shared.ldap.schema.DITStructureRule; @@ -136,7 +135,7 @@ // stuff for dealing with subentries (garbage for now) String subschemaSubentry = ( String ) nexus.getRootDSE().get( "subschemaSubentry" ).get(); - subschemaSubentryDn = new LdapName( subschemaSubentry ).toString().toLowerCase(); + subschemaSubentryDn = new LdapDN( subschemaSubentry ).toString().toLowerCase(); } @@ -154,7 +153,7 @@ } - public NamingEnumeration list( NextInterceptor nextInterceptor, Name base ) throws NamingException + public NamingEnumeration list( NextInterceptor nextInterceptor, LdapDN base ) throws NamingException { NamingEnumeration e = nextInterceptor.list( base ); Invocation invocation = InvocationStack.getInstance().peek(); @@ -162,7 +161,7 @@ } - public NamingEnumeration search( NextInterceptor nextInterceptor, Name base, Map env, ExprNode filter, + public NamingEnumeration search( NextInterceptor nextInterceptor, LdapDN base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException { // check to make sure the DN searched for is a subentry @@ -395,7 +394,7 @@ } - public Attributes lookup( NextInterceptor nextInterceptor, Name name ) throws NamingException + public Attributes lookup( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException { Attributes result = nextInterceptor.lookup( name ); filterBinaryAttributes( result ); @@ -404,7 +403,7 @@ } - public Attributes lookup( NextInterceptor nextInterceptor, Name name, String[] attrIds ) throws NamingException + public Attributes lookup( NextInterceptor nextInterceptor, LdapDN name, String[] attrIds ) throws NamingException { Attributes result = nextInterceptor.lookup( name, attrIds ); if ( result == null ) @@ -574,7 +573,7 @@ } - public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException + public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes mods ) throws NamingException { Attributes entry = nexus.lookup( name ); Attribute objectClass = getResultantObjectClasses( modOp, mods.get( "objectClass" ), entry.get( "objectClass" ) ); @@ -670,7 +669,7 @@ } - public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException + public void modify( NextInterceptor next, LdapDN name, ModificationItem[] mods ) throws NamingException { Attributes entry = nexus.lookup( name ); Set modset = new HashSet(); @@ -734,7 +733,8 @@ { throw new LdapSchemaViolationException( ResultCodeEnum.OBJECTCLASSVIOLATION ); } - SchemaChecker.preventRdnChangeOnModifyRemove( name, modOp, change ); + SchemaChecker.preventRdnChangeOnModifyRemove( name, modOp, change, + this.globalRegistries.getOidRegistry() ); SchemaChecker .preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, modOp, change, objectClass ); } @@ -908,7 +908,7 @@ /** * Check that all the attributes exist in the schema for this entry. */ - public void add( NextInterceptor next, String upName, Name normName, Attributes attrs ) throws NamingException + public void add(NextInterceptor next, LdapDN normName, Attributes attrs) throws NamingException { AttributeTypeRegistry atRegistry = this.globalRegistries.getAttributeTypeRegistry(); NamingEnumeration attrEnum = attrs.getIDs(); @@ -922,6 +922,6 @@ } alterObjectClasses( attrs.get( "objectClass" ), this.globalRegistries.getObjectClassRegistry() ); - next.add( upName, normName, attrs ); + next.add(normName, attrs ); } } Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapAttributeTypeRegistry.java Tue Jun 13 20:22:05 2006 @@ -17,6 +17,7 @@ package org.apache.directory.server.core.schema.bootstrap; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -26,6 +27,11 @@ import org.apache.directory.server.core.schema.AttributeTypeRegistry; import org.apache.directory.server.core.schema.OidRegistry; import org.apache.directory.shared.ldap.schema.AttributeType; +import org.apache.directory.shared.ldap.schema.MatchingRule; +import org.apache.directory.shared.ldap.schema.NoOpNormalizer; +import org.apache.directory.shared.ldap.schema.OidNormalizer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,13 +47,16 @@ { /** static class logger */ private final static Logger log = LoggerFactory.getLogger( BootstrapAttributeTypeRegistry.class ); + /** maps an OID to an AttributeType */ private final Map byOid; /** maps an OID to a schema name*/ private final Map oidToSchema; /** the registry used to resolve names to OIDs */ private final OidRegistry oidRegistry; - + /** cached normalizer mapping */ + private transient Map mapping; + // ------------------------------------------------------------------------ // C O N S T R U C T O R S @@ -145,5 +154,40 @@ public Iterator list() { return byOid.values().iterator(); + } + + + public Map getNormalizerMapping() throws NamingException + { + if ( mapping == null ) + { + mapping = new HashMap( byOid.size() << 1 ); + for ( Iterator ii = byOid.values().iterator(); ii.hasNext(); /**/ ) + { + AttributeType type = ( AttributeType ) ii.next(); + MatchingRule matchingRule = type.getEquality(); + OidNormalizer oidNormalizer = null; + + if ( matchingRule == null ) + { + log.warn( "Attribute " + type.getName() + " does not have normalizer : using NoopNormalizer" ); + oidNormalizer = new OidNormalizer( type.getOid(), new NoOpNormalizer() ); + } + else + { + oidNormalizer = new OidNormalizer( type.getOid(), matchingRule.getNormalizer() ); + } + + mapping.put( type.getOid(), oidNormalizer ); + String[] aliases = type.getNames(); + for ( int jj = 0; jj < aliases.length; jj++ ) + { + mapping.put( aliases[jj], oidNormalizer ); + mapping.put( aliases[jj].toLowerCase(), oidNormalizer ); + } + } + } + + return Collections.unmodifiableMap( mapping ); } } Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemComparatorProducer.java Tue Jun 13 20:22:05 2006 @@ -21,13 +21,12 @@ import javax.naming.NamingException; -import org.apache.directory.server.core.schema.ConcreteNameComponentNormalizer; +import org.apache.directory.server.core.schema.DnComparator; import org.apache.directory.server.core.schema.bootstrap.ProducerTypeEnum; import org.apache.directory.shared.ldap.schema.CachingNormalizer; import org.apache.directory.shared.ldap.schema.ComparableComparator; import org.apache.directory.shared.ldap.schema.DeepTrimNormalizer; import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer; -import org.apache.directory.shared.ldap.schema.DnComparator; import org.apache.directory.shared.ldap.schema.NormalizingComparator; import org.apache.directory.shared.ldap.schema.ObjectIdentifierComparator; @@ -63,7 +62,7 @@ ( 2.5.13.1 NAME 'distinguishedNameMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) */ - comparator = new DnComparator( new ConcreteNameComponentNormalizer( registries.getAttributeTypeRegistry() ) ); + comparator = new DnComparator( registries.getAttributeTypeRegistry() ); cb.schemaObjectProduced( this, "2.5.13.1", comparator ); /* Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/SystemNormalizerProducer.java Tue Jun 13 20:22:05 2006 @@ -19,12 +19,11 @@ import javax.naming.NamingException; -import org.apache.directory.server.core.schema.ConcreteNameComponentNormalizer; +import org.apache.directory.server.core.schema.DnNormalizer; import org.apache.directory.server.core.schema.bootstrap.ProducerTypeEnum; import org.apache.directory.shared.ldap.schema.CachingNormalizer; import org.apache.directory.shared.ldap.schema.DeepTrimNormalizer; import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer; -import org.apache.directory.shared.ldap.schema.DnNormalizer; import org.apache.directory.shared.ldap.schema.NoOpNormalizer; import org.apache.directory.shared.ldap.schema.Normalizer; import org.apache.directory.shared.ldap.schema.ObjectIdentifierNormalizer; @@ -56,8 +55,7 @@ ( 2.5.13.1 NAME 'distinguishedNameMatch' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) */ - normalizer = new CachingNormalizer( new DnNormalizer( new ConcreteNameComponentNormalizer( registries - .getAttributeTypeRegistry() ) ) ); + normalizer = new CachingNormalizer( new DnNormalizer( registries.getAttributeTypeRegistry() ) ); cb.schemaObjectProduced( this, "2.5.13.1", normalizer ); /* Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java Tue Jun 13 20:22:05 2006 @@ -18,6 +18,7 @@ import org.apache.directory.server.core.DirectoryServiceConfiguration; +import org.apache.directory.server.core.ServerUtils; import org.apache.directory.server.core.configuration.InterceptorConfiguration; import org.apache.directory.server.core.enumeration.SearchResultFilter; import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration; @@ -26,7 +27,9 @@ import org.apache.directory.server.core.invocation.Invocation; import org.apache.directory.server.core.invocation.InvocationStack; import org.apache.directory.server.core.partition.DirectoryPartitionNexus; -import org.apache.directory.server.core.schema.ConcreteNameComponentNormalizer; +import org.apache.directory.server.core.schema.AttributeTypeRegistry; +import org.apache.directory.server.core.schema.OidRegistry; + import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException; import org.apache.directory.shared.ldap.exception.LdapNoSuchAttributeException; import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException; @@ -38,8 +41,9 @@ import org.apache.directory.shared.ldap.message.LockableAttributesImpl; import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.message.SubentriesControl; -import org.apache.directory.shared.ldap.name.DnParser; -import org.apache.directory.shared.ldap.name.LdapName; +import org.apache.directory.shared.ldap.name.LdapDN; +import org.apache.directory.shared.ldap.schema.AttributeType; +import org.apache.directory.shared.ldap.schema.NormalizerMappingResolver; import org.apache.directory.shared.ldap.subtree.SubtreeSpecification; import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationParser; @@ -97,10 +101,15 @@ /** the hash mapping the DN of a subentry to its SubtreeSpecification */ private final Map subtrees = new HashMap(); private DirectoryServiceConfiguration factoryCfg; - private DnParser dnParser; private SubtreeSpecificationParser ssParser; private SubtreeEvaluator evaluator; private DirectoryPartitionNexus nexus; + private AttributeTypeRegistry attrRegistry; + private OidRegistry oidRegistry; + + + private AttributeType objectClassType; + private AttributeType administrativeRoleType; public void init( DirectoryServiceConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException @@ -108,14 +117,24 @@ super.init( factoryCfg, cfg ); this.nexus = factoryCfg.getPartitionNexus(); this.factoryCfg = factoryCfg; - ConcreteNameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( factoryCfg.getGlobalRegistries() - .getAttributeTypeRegistry() ); - ssParser = new SubtreeSpecificationParser( ncn ); - dnParser = new DnParser( ncn ); + this.attrRegistry = factoryCfg.getGlobalRegistries().getAttributeTypeRegistry(); + this.oidRegistry = factoryCfg.getGlobalRegistries().getOidRegistry(); + + // setup various attribute type values + objectClassType = attrRegistry.lookup( oidRegistry.getOid( "objectClass" ) ); + administrativeRoleType = attrRegistry.lookup( oidRegistry.getOid( "administrativeRole" ) ); + + ssParser = new SubtreeSpecificationParser( new NormalizerMappingResolver() + { + public Map getNormalizerMapping() throws NamingException + { + return attrRegistry.getNormalizerMapping(); + } + }); evaluator = new SubtreeEvaluator( factoryCfg.getGlobalRegistries().getOidRegistry() ); // prepare to find all subentries in all namingContexts - Iterator suffixes = this.nexus.listSuffixes( true ); + Iterator suffixes = this.nexus.listSuffixes(); ExprNode filter = new SimpleNode( "objectclass", "subentry", LeafNode.EQUALITY ); SearchControls controls = new SearchControls(); controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); @@ -125,7 +144,9 @@ // search each namingContext for subentries while ( suffixes.hasNext() ) { - Name suffix = dnParser.parse( ( String ) suffixes.next() ); + LdapDN suffix = new LdapDN( ( String ) suffixes.next() ); + //suffix = LdapDN.normalize( suffix, registry.getNormalizerMapping() ); + suffix.normalize(); NamingEnumeration subentries = nexus.search( suffix, factoryCfg.getEnvironment(), filter, controls ); while ( subentries.hasMore() ) { @@ -145,7 +166,10 @@ continue; } - subtrees.put( dnParser.parse( dn ).toString(), ss ); + LdapDN dnName = new LdapDN( dn ); + //dnName = LdapDN.normalize( dnName, registry.getNormalizerMapping() ); + dnName.normalize(); + subtrees.put( dnName.toString(), ss ); } } } @@ -155,7 +179,7 @@ // Methods/Code dealing with Subentry Visibility // ----------------------------------------------------------------------- - public NamingEnumeration list( NextInterceptor nextInterceptor, Name base ) throws NamingException + public NamingEnumeration list( NextInterceptor nextInterceptor, LdapDN base ) throws NamingException { NamingEnumeration e = nextInterceptor.list( base ); Invocation invocation = InvocationStack.getInstance().peek(); @@ -170,7 +194,7 @@ } - public NamingEnumeration search( NextInterceptor nextInterceptor, Name base, Map env, ExprNode filter, + public NamingEnumeration search( NextInterceptor nextInterceptor, LdapDN base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException { NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls ); @@ -248,10 +272,10 @@ while ( list.hasNext() ) { String subentryDnStr = ( String ) list.next(); - Name subentryDn = new LdapName( subentryDnStr ); - Name apDn = ( Name ) subentryDn.clone(); + LdapDN subentryDn = new LdapDN( subentryDnStr ); + LdapDN apDn = ( LdapDN ) subentryDn.clone(); apDn.remove( apDn.size() - 1 ); - SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDn ); + SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDnStr ); if ( evaluator.evaluate( ss, apDn, dn, objectClasses ) ) { @@ -326,14 +350,14 @@ } - public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException + public void add( NextInterceptor next, LdapDN normName, Attributes entry ) throws NamingException { Attribute objectClasses = entry.get( "objectClass" ); if ( objectClasses.contains( "subentry" ) ) { // get the name of the administrative point and its administrativeRole attributes - Name apName = ( Name ) normName.clone(); + LdapDN apName = ( LdapDN ) normName.clone(); apName.remove( normName.size() - 1 ); Attributes ap = nexus.lookup( apName ); Attribute administrativeRole = ap.get( "administrativeRole" ); @@ -372,12 +396,12 @@ } catch ( Exception e ) { - String msg = "Failed while parsing subtreeSpecification for " + upName; + String msg = "Failed while parsing subtreeSpecification for " + normName.toUpName(); log.warn( msg ); throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX ); } subtrees.put( normName.toString(), ss ); - next.add( upName, normName, entry ); + next.add(normName, entry ); /* ---------------------------------------------------------------- * Find the baseDn for the subentry and use that to search the tree @@ -387,10 +411,10 @@ * operational attributes calculated above. * ---------------------------------------------------------------- */ - Name baseDn = ( Name ) apName.clone(); + LdapDN baseDn = ( LdapDN ) apName.clone(); baseDn.addAll( ss.getBase() ); - ExprNode filter = new PresenceNode( "objectclass" ); + ExprNode filter = new PresenceNode( "2.5.4.0" ); // (objectClass=*) SearchControls controls = new SearchControls(); controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); controls.setReturningAttributes( new String[] @@ -401,7 +425,8 @@ { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) ) { @@ -415,10 +440,10 @@ while ( list.hasNext() ) { String subentryDnStr = ( String ) list.next(); - Name subentryDn = new LdapName( subentryDnStr ); - Name apDn = ( Name ) subentryDn.clone(); + LdapDN subentryDn = new LdapDN( subentryDnStr ); + LdapDN apDn = ( LdapDN ) subentryDn.clone(); apDn.remove( apDn.size() - 1 ); - SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDn ); + SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDn.toNormName() ); if ( evaluator.evaluate( ss, apDn, normName, objectClasses ) ) { @@ -493,7 +518,7 @@ } } - next.add( upName, normName, entry ); + next.add(normName, entry ); } } @@ -502,15 +527,14 @@ // Methods dealing subentry deletion // ----------------------------------------------------------------------- - public void delete( NextInterceptor next, Name name ) throws NamingException + public void delete( NextInterceptor next, LdapDN name ) throws NamingException { Attributes entry = nexus.lookup( name ); - Attribute objectClasses = entry.get( "objectClass" ); + Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry ); if ( objectClasses.contains( "subentry" ) ) { - SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( name.toString() ); - subtrees.remove( ss ); + SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.remove( name.toNormName() ); next.delete( name ); /* ---------------------------------------------------------------- @@ -521,12 +545,12 @@ * attributes we remove from the entry in a modify operation. * ---------------------------------------------------------------- */ - Name apName = ( Name ) name.clone(); + LdapDN apName = ( LdapDN ) name.clone(); apName.remove( name.size() - 1 ); - Name baseDn = ( Name ) apName.clone(); + LdapDN baseDn = ( LdapDN ) apName.clone(); baseDn.addAll( ss.getBase() ); - ExprNode filter = new PresenceNode( "objectclass" ); + ExprNode filter = new PresenceNode( oidRegistry.getOid( "objectclass" ) ); SearchControls controls = new SearchControls(); controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); controls.setReturningAttributes( new String[] @@ -537,9 +561,10 @@ { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); - if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) ) + if ( evaluator.evaluate( ss, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) ) { nexus.modify( dn, getOperationalModsForRemove( name, candidate ) ); } @@ -565,7 +590,7 @@ * are, false otherwise * @throws NamingException if there are errors while searching the directory */ - private boolean hasAdministrativeDescendant( Name name ) throws NamingException + private boolean hasAdministrativeDescendant( LdapDN name ) throws NamingException { ExprNode filter = new PresenceNode( "administrativeRole" ); SearchControls controls = new SearchControls(); @@ -604,7 +629,7 @@ while ( subentries.hasNext() ) { String subentryDn = ( String ) subentries.next(); - Name apDn = new LdapName( subentryDn ); + Name apDn = new LdapDN( subentryDn ); apDn.remove( apDn.size() - 1 ); SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( subentryDn ); boolean isOldNameSelected = evaluator.evaluate( ss, apDn, oldName, objectClasses ); @@ -655,41 +680,44 @@ } - public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException + public void modifyRn( NextInterceptor next, LdapDN name, String newRn, boolean deleteOldRn ) throws NamingException { Attributes entry = nexus.lookup( name ); - Attribute objectClasses = entry.get( "objectClass" ); + Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry ); if ( objectClasses.contains( "subentry" ) ) { - SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( name.toString() ); - Name apName = ( Name ) name.clone(); + SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( name.toNormName() ); + LdapDN apName = ( LdapDN ) name.clone(); apName.remove( apName.size() - 1 ); - Name baseDn = ( Name ) apName.clone(); + LdapDN baseDn = ( LdapDN ) apName.clone(); baseDn.addAll( ss.getBase() ); - Name newName = ( Name ) name.clone(); + LdapDN newName = ( LdapDN ) name.clone(); newName.remove( newName.size() - 1 ); - Name rdn = dnParser.parse( newRn ); + + LdapDN rdn = new LdapDN( newRn ); newName.addAll( rdn ); + rdn.normalize(); + newName.normalize(); - subtrees.put( newName.toString(), ss ); + subtrees.put( newName.toNormName(), ss ); next.modifyRn( name, newRn, deleteOldRn ); Attributes apAttrs = nexus.lookup( apName ); - Attribute administrativeRole = apAttrs.get( "administrativeRole" ); - ExprNode filter = new PresenceNode( "objectclass" ); + Attribute administrativeRole = ServerUtils.getAttribute( administrativeRoleType, apAttrs ); + ExprNode filter = new PresenceNode( oidRegistry.getOid( "objectclass" ) ); SearchControls controls = new SearchControls(); controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - controls.setReturningAttributes( new String[] - { "+", "*" } ); + controls.setReturningAttributes( new String[] { "+", "*" } ); NamingEnumeration subentries = nexus.search( baseDn, factoryCfg.getEnvironment(), filter, controls ); while ( subentries.hasMore() ) { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); - if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) ) + if ( evaluator.evaluate( ss, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) ) { nexus.modify( dn, getOperationalModsForReplace( name, newName, administrativeRole, candidate ) ); } @@ -707,9 +735,10 @@ // calculate the new DN now for use below to modify subentry operational // attributes contained within this regular entry with name changes - Name newName = ( Name ) name.clone(); + LdapDN newName = ( LdapDN ) name.clone(); newName.remove( newName.size() - 1 ); newName.add( newRn ); + newName.normalize(); ModificationItem[] mods = getModsOnEntryRdnChange( name, newName, entry ); if ( mods.length > 0 ) @@ -720,43 +749,46 @@ } - public void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) + public void move( NextInterceptor next, LdapDN oriChildName, LdapDN newParentName, String newRn, boolean deleteOldRn ) throws NamingException { Attributes entry = nexus.lookup( oriChildName ); - Attribute objectClasses = entry.get( "objectClass" ); + Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry ); if ( objectClasses.contains( "subentry" ) ) { - SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( oriChildName.toString() ); - Name apName = ( Name ) oriChildName.clone(); + SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( oriChildName.toNormName() ); + LdapDN apName = ( LdapDN ) oriChildName.clone(); apName.remove( apName.size() - 1 ); - Name baseDn = ( Name ) apName.clone(); + LdapDN baseDn = ( LdapDN ) apName.clone(); baseDn.addAll( ss.getBase() ); - Name newName = ( Name ) newParentName.clone(); + LdapDN newName = ( LdapDN ) newParentName.clone(); newName.remove( newName.size() - 1 ); - Name rdn = dnParser.parse( newRn ); - newName.addAll( rdn ); - subtrees.put( newName.toString(), ss ); + LdapDN rdn = new LdapDN( newRn ); + newName.addAll( rdn ); + rdn.normalize(); + newName.normalize(); + + subtrees.put( newName.toNormName(), ss ); next.move( oriChildName, newParentName, newRn, deleteOldRn ); Attributes apAttrs = nexus.lookup( apName ); - Attribute administrativeRole = apAttrs.get( "administrativeRole" ); + Attribute administrativeRole = ServerUtils.getAttribute( administrativeRoleType, apAttrs ); - ExprNode filter = new PresenceNode( "objectclass" ); + ExprNode filter = new PresenceNode( oidRegistry.getOid( "objectclass" ) ); SearchControls controls = new SearchControls(); controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - controls.setReturningAttributes( new String[] - { "+", "*" } ); + controls.setReturningAttributes( new String[] { "+", "*" } ); NamingEnumeration subentries = nexus.search( baseDn, factoryCfg.getEnvironment(), filter, controls ); while ( subentries.hasMore() ) { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); - if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) ) + if ( evaluator.evaluate( ss, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) ) { nexus.modify( dn, getOperationalModsForReplace( oriChildName, newName, administrativeRole, candidate ) ); @@ -775,8 +807,9 @@ // calculate the new DN now for use below to modify subentry operational // attributes contained within this regular entry with name changes - Name newName = ( Name ) newParentName.clone(); + LdapDN newName = ( LdapDN ) newParentName.clone(); newName.add( newRn ); + newName.normalize(); ModificationItem[] mods = getModsOnEntryRdnChange( oriChildName, newName, entry ); if ( mods.length > 0 ) @@ -787,7 +820,7 @@ } - public void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException + public void move( NextInterceptor next, LdapDN oriChildName, LdapDN newParentName ) throws NamingException { Attributes entry = nexus.lookup( oriChildName ); Attribute objectClasses = entry.get( "objectClass" ); @@ -795,11 +828,11 @@ if ( objectClasses.contains( "subentry" ) ) { SubtreeSpecification ss = ( SubtreeSpecification ) subtrees.get( oriChildName.toString() ); - Name apName = ( Name ) oriChildName.clone(); + LdapDN apName = ( LdapDN ) oriChildName.clone(); apName.remove( apName.size() - 1 ); - Name baseDn = ( Name ) apName.clone(); + LdapDN baseDn = ( LdapDN ) apName.clone(); baseDn.addAll( ss.getBase() ); - Name newName = ( Name ) newParentName.clone(); + LdapDN newName = ( LdapDN ) newParentName.clone(); newName.remove( newName.size() - 1 ); newName.add( newParentName.get( newParentName.size() - 1 ) ); @@ -819,7 +852,8 @@ { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) ) { @@ -840,7 +874,7 @@ // calculate the new DN now for use below to modify subentry operational // attributes contained within this regular entry with name changes - Name newName = ( Name ) newParentName.clone(); + LdapDN newName = ( LdapDN ) newParentName.clone(); newName.add( oriChildName.get( oriChildName.size() - 1 ) ); ModificationItem[] mods = getModsOnEntryRdnChange( oriChildName, newName, entry ); @@ -856,14 +890,14 @@ // Methods dealing subentry modification // ----------------------------------------------------------------------- - public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException + public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes mods ) throws NamingException { Attributes entry = nexus.lookup( name ); - Attribute objectClasses = entry.get( "objectClass" ); + Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry ); if ( objectClasses.contains( "subentry" ) && mods.get( "subtreeSpecification" ) != null ) { - SubtreeSpecification ssOld = ( SubtreeSpecification ) subtrees.remove( name.toString() ); + SubtreeSpecification ssOld = ( SubtreeSpecification ) subtrees.remove( name.toNormName() ); SubtreeSpecification ssNew; try @@ -877,15 +911,15 @@ throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX ); } - subtrees.put( name.toString(), ssNew ); + subtrees.put( name.toNormName(), ssNew ); next.modify( name, modOp, mods ); // search for all entries selected by the old SS and remove references to subentry - Name apName = ( Name ) name.clone(); + LdapDN apName = ( LdapDN ) name.clone(); apName.remove( apName.size() - 1 ); - Name oldBaseDn = ( Name ) apName.clone(); + LdapDN oldBaseDn = ( LdapDN ) apName.clone(); oldBaseDn.addAll( ssOld.getBase() ); - ExprNode filter = new PresenceNode( "objectClass" ); + ExprNode filter = new PresenceNode( oidRegistry.getOid( "objectClass" ) ); SearchControls controls = new SearchControls(); controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); controls.setReturningAttributes( new String[] @@ -895,9 +929,10 @@ { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); - if ( evaluator.evaluate( ssOld, apName, dn, candidate.get( "objectClass" ) ) ) + if ( evaluator.evaluate( ssOld, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) ) { nexus.modify( dn, getOperationalModsForRemove( name, candidate ) ); } @@ -905,18 +940,19 @@ // search for all selected entries by the new SS and add references to subentry Attributes apAttrs = nexus.lookup( apName ); - Attribute administrativeRole = apAttrs.get( "administrativeRole" ); + Attribute administrativeRole = ServerUtils.getAttribute( administrativeRoleType, apAttrs ); Attributes operational = getSubentryOperatationalAttributes( name, administrativeRole ); - Name newBaseDn = ( Name ) apName.clone(); + LdapDN newBaseDn = ( LdapDN ) apName.clone(); newBaseDn.addAll( ssNew.getBase() ); subentries = nexus.search( newBaseDn, factoryCfg.getEnvironment(), filter, controls ); while ( subentries.hasMore() ) { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); - if ( evaluator.evaluate( ssNew, apName, dn, candidate.get( "objectClass" ) ) ) + if ( evaluator.evaluate( ssNew, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) ) { nexus.modify( dn, getOperationalModsForAdd( candidate, operational ) ); } @@ -929,10 +965,10 @@ } - public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException + public void modify( NextInterceptor next, LdapDN name, ModificationItem[] mods ) throws NamingException { Attributes entry = nexus.lookup( name ); - Attribute objectClasses = entry.get( "objectClass" ); + Attribute objectClasses = ServerUtils.getAttribute( objectClassType, entry ); boolean isSubtreeSpecificationModification = false; ModificationItem subtreeMod = null; @@ -961,15 +997,15 @@ throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX ); } - subtrees.put( name.toString(), ssNew ); + subtrees.put( name.toNormName(), ssNew ); next.modify( name, mods ); // search for all entries selected by the old SS and remove references to subentry - Name apName = ( Name ) name.clone(); + LdapDN apName = ( LdapDN ) name.clone(); apName.remove( apName.size() - 1 ); - Name oldBaseDn = ( Name ) apName.clone(); + LdapDN oldBaseDn = ( LdapDN ) apName.clone(); oldBaseDn.addAll( ssOld.getBase() ); - ExprNode filter = new PresenceNode( "objectClass" ); + ExprNode filter = new PresenceNode( oidRegistry.getOid( "objectClass" ) ); SearchControls controls = new SearchControls(); controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); controls.setReturningAttributes( new String[] @@ -979,7 +1015,8 @@ { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); if ( evaluator.evaluate( ssOld, apName, dn, candidate.get( "objectClass" ) ) ) { @@ -991,14 +1028,15 @@ Attributes apAttrs = nexus.lookup( apName ); Attribute administrativeRole = apAttrs.get( "administrativeRole" ); Attributes operational = getSubentryOperatationalAttributes( name, administrativeRole ); - Name newBaseDn = ( Name ) apName.clone(); + LdapDN newBaseDn = ( LdapDN ) apName.clone(); newBaseDn.addAll( ssNew.getBase() ); subentries = nexus.search( newBaseDn, factoryCfg.getEnvironment(), filter, controls ); while ( subentries.hasMore() ) { SearchResult result = ( SearchResult ) subentries.next(); Attributes candidate = result.getAttributes(); - Name dn = dnParser.parse( result.getName() ); + LdapDN dn = new LdapDN( result.getName() ); + dn.normalize(); if ( evaluator.evaluate( ssNew, apName, dn, candidate.get( "objectClass" ) ) ) { @@ -1214,10 +1252,10 @@ * @return the set of modifications required to remove an entry's reference to * a subentry */ - private ModificationItem[] getOperationalModsForRemove( Name subentryDn, Attributes candidate ) + private ModificationItem[] getOperationalModsForRemove( LdapDN subentryDn, Attributes candidate ) { List modList = new ArrayList(); - String dn = subentryDn.toString(); + String dn = subentryDn.toNormName(); for ( int ii = 0; ii < SUBENTRY_OPATTRS.length; ii++ ) { @@ -1334,12 +1372,18 @@ if ( !result.isRelative() ) { - String normalizedDn = dnParser.parse( dn ).toString(); + LdapDN ndn = new LdapDN( dn ); + ndn.normalize(); + String normalizedDn = ndn.toString(); return !subtrees.containsKey( normalizedDn ); } - Name name = dnParser.parse( invocation.getCaller().getNameInNamespace() ); - name.addAll( dnParser.parse( result.getName() ) ); + LdapDN name = new LdapDN( invocation.getCaller().getNameInNamespace() ); + name.normalize(); + + LdapDN rest = new LdapDN( result.getName() ); + rest.normalize(); + name.addAll( rest ); return !subtrees.containsKey( name.toString() ); } } @@ -1389,13 +1433,18 @@ if ( !result.isRelative() ) { - String normalizedDn = dnParser.parse( dn ).toString(); - return subtrees.containsKey( normalizedDn ); + LdapDN ndn = new LdapDN( dn ); + ndn.normalize(); + return subtrees.containsKey( ndn.toNormName() ); } - Name name = dnParser.parse( invocation.getCaller().getNameInNamespace() ); - name.addAll( dnParser.parse( result.getName() ) ); - return subtrees.containsKey( name.toString() ); + LdapDN name = new LdapDN( invocation.getCaller().getNameInNamespace() ); + name.normalize(); + + LdapDN rest = new LdapDN( result.getName() ); + rest.normalize(); + name.addAll( rest ); + return subtrees.containsKey( name.toNormName() ); } } } Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java (original) +++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubtreeEvaluator.java Tue Jun 13 20:22:05 2006 @@ -18,7 +18,7 @@ import org.apache.directory.server.core.schema.OidRegistry; -import org.apache.directory.shared.ldap.name.LdapName; +import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.subtree.SubtreeSpecification; import org.apache.directory.shared.ldap.util.NamespaceTools; @@ -90,7 +90,7 @@ } else if ( apDn.equals( entryDn ) ) { - apRelativeRdn = new LdapName(); + apRelativeRdn = new LdapDN(); } else { @@ -110,7 +110,7 @@ } else if ( apRelativeRdn.equals( subtree.getBase() ) ) { - baseRelativeRdn = new LdapName(); + baseRelativeRdn = new LdapDN(); } else if ( !NamespaceTools.isDescendant( subtree.getBase(), apRelativeRdn ) ) { Modified: directory/trunks/apacheds/core/src/main/schema/apache.schema URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/schema/apache.schema?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/main/schema/apache.schema (original) +++ directory/trunks/apacheds/core/src/main/schema/apache.schema Tue Jun 13 20:22:05 2006 @@ -18,8 +18,7 @@ attributetype ( 1.2.6.1.4.1.18060.1.1.1.3.1 NAME 'apacheNdn' DESC 'Index attribute DN whose values are normalized based on schema' - SUP distinguishedName - EQUALITY distinguishedNameMatch + EQUALITY exactDnAsStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE NO-USER-MODIFICATION Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java (original) +++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyAttributeTypeRegistry.java Tue Jun 13 20:22:05 2006 @@ -20,7 +20,9 @@ import java.util.ArrayList; +import java.util.Comparator; import java.util.Iterator; +import java.util.Map; import javax.naming.NamingException; @@ -28,8 +30,11 @@ import org.apache.directory.server.core.schema.AttributeTypeRegistry; import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.MatchingRule; +import org.apache.directory.shared.ldap.schema.Normalizer; import org.apache.directory.shared.ldap.schema.Syntax; +import org.apache.directory.shared.ldap.schema.SyntaxChecker; import org.apache.directory.shared.ldap.schema.UsageEnum; +import org.apache.directory.shared.ldap.util.StringTools; /** @@ -105,7 +110,56 @@ public MatchingRule getEquality() throws NamingException { - return null; + return new MatchingRule() + { + + public Syntax getSyntax() throws NamingException + { + return null; + } + + public Comparator getComparator() throws NamingException + { + return null; + } + + public Normalizer getNormalizer() throws NamingException + { + return new Normalizer() + { + public Object normalize( Object value ) throws NamingException + { + return StringTools.deepTrimToLower( value.toString() ); + } + }; + } + + public boolean isObsolete() + { + return false; + } + + public String getOid() + { + return null; + } + + public String[] getNames() + { + return null; + } + + public String getName() + { + return null; + } + + public String getDescription() + { + return null; + } + + }; } @@ -188,7 +242,45 @@ public Syntax getSyntax() throws NamingException { - return null; + return new Syntax() + { + + public boolean isHumanReadible() + { + return true; + } + + public SyntaxChecker getSyntaxChecker() throws NamingException + { + return null; + } + + public boolean isObsolete() + { + return false; + } + + public String getOid() + { + return null; + } + + public String[] getNames() + { + return null; + } + + public String getName() + { + return null; + } + + public String getDescription() + { + return null; + } + + }; } @@ -200,7 +292,94 @@ public MatchingRule getEquality() throws NamingException { - return null; + return new MatchingRule() + { + + public Syntax getSyntax() throws NamingException + { + return new Syntax() + { + + public boolean isHumanReadible() + { + return true; + } + + public SyntaxChecker getSyntaxChecker() throws NamingException + { + return null; + } + + public boolean isObsolete() + { + return false; + } + + public String getOid() + { + return null; + } + + public String[] getNames() + { + return null; + } + + public String getName() + { + return null; + } + + public String getDescription() + { + return null; + } + + }; + } + + public Comparator getComparator() throws NamingException + { + return null; + } + + public Normalizer getNormalizer() throws NamingException + { + return new Normalizer() + { + public Object normalize( Object value ) throws NamingException + { + return StringTools.deepTrimToLower( value.toString() ); + } + }; + } + + public boolean isObsolete() + { + return false; + } + + public String getOid() + { + return null; + } + + public String[] getNames() + { + return null; + } + + public String getName() + { + return null; + } + + public String getDescription() + { + return null; + } + + }; } @@ -267,4 +446,9 @@ return new ArrayList().iterator(); } + + public Map getNormalizerMapping() throws NamingException + { + return null; + } } Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java?rev=414035&r1=414034&r2=414035&view=diff ============================================================================== --- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java (original) +++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/DummyOidRegistry.java Tue Jun 13 20:22:05 2006 @@ -41,7 +41,7 @@ { public String getOid( String name ) throws NamingException { - return String.valueOf( name.hashCode() ); + return name.toLowerCase(); }