Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 41524 invoked from network); 2 Jun 2007 17:22:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jun 2007 17:22:09 -0000 Received: (qmail 21731 invoked by uid 500); 2 Jun 2007 17:22:13 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 21679 invoked by uid 500); 2 Jun 2007 17:22:13 -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 21668 invoked by uid 99); 2 Jun 2007 17:22:13 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2007 10:22:13 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2007 10:22:08 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id B79BE1A981A; Sat, 2 Jun 2007 10:21:48 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r543764 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi: ServerContext.java ServerDirContext.java Date: Sat, 02 Jun 2007 17:21:48 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070602172148.B79BE1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Sat Jun 2 10:21:47 2007 New Revision: 543764 URL: http://svn.apache.org/viewvc?view=rev&rev=543764 Log: Added calls to AttributeUtils.toCaseInsensitive() so that even if a user pass a case sensitive BasicAttributes() to the server, it will get the expected response. Search method now returns an Enumeration Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?view=diff&rev=543764&r1=543763&r2=543764 ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Sat Jun 2 10:21:47 2007 @@ -26,6 +26,7 @@ import java.util.Iterator; import java.util.Set; +import javax.naming.Binding; import javax.naming.Context; import javax.naming.InvalidNameException; import javax.naming.Name; @@ -70,6 +71,7 @@ import org.apache.directory.shared.ldap.name.AttributeTypeAndValue; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.name.Rdn; +import org.apache.directory.shared.ldap.util.AttributeUtils; import org.apache.directory.shared.ldap.util.StringTools; @@ -388,7 +390,9 @@ { // First, use state factories to do a transformation DirStateFactory.Result res = DirectoryManager.getStateToBind( obj, name, this, env, null ); - Attributes outAttrs = res.getAttributes(); + + // let's be sure that the Attributes is case insensitive + Attributes outAttrs = AttributeUtils.toCaseInsensitive( res.getAttributes() ); if ( outAttrs != null ) { Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?view=diff&rev=543764&r1=543763&r2=543764 ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Sat Jun 2 10:21:47 2007 @@ -37,6 +37,7 @@ import javax.naming.directory.InvalidSearchFilterException; import javax.naming.directory.ModificationItem; import javax.naming.directory.SearchControls; +import javax.naming.directory.SearchResult; import javax.naming.event.EventDirContext; import javax.naming.event.NamingListener; import javax.naming.spi.DirStateFactory; @@ -62,6 +63,7 @@ import org.apache.directory.shared.ldap.name.AttributeTypeAndValue; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.name.Rdn; +import org.apache.directory.shared.ldap.util.AttributeUtils; import org.apache.directory.shared.ldap.util.StringTools; @@ -157,7 +159,7 @@ */ public void modifyAttributes( String name, int modOp, Attributes attrs ) throws NamingException { - modifyAttributes( new LdapDN( name ), modOp, attrs ); + modifyAttributes( new LdapDN( name ), modOp, AttributeUtils.toCaseInsensitive( attrs ) ); } /** @@ -250,7 +252,7 @@ */ public void bind( String name, Object obj, Attributes attrs ) throws NamingException { - bind( new LdapDN( name ), obj, attrs ); + bind( new LdapDN( name ), obj, AttributeUtils.toCaseInsensitive( attrs ) ); } @@ -260,7 +262,7 @@ */ public void bind( Name name, Object obj, Attributes attrs ) throws NamingException { - if ( null == obj && null == attrs ) + if ( ( null == obj ) && ( null == attrs ) ) { throw new NamingException( "Both obj and attrs args are null. " + "At least one of these parameters must not be null." ); @@ -273,6 +275,8 @@ return; } + attrs = AttributeUtils.toCaseInsensitive( attrs ); + // No object binding so we just add the attributes if ( null == obj ) { @@ -360,7 +364,7 @@ */ public void rebind( String name, Object obj, Attributes attrs ) throws NamingException { - rebind( new LdapDN( name ), obj, attrs ); + rebind( new LdapDN( name ), obj, AttributeUtils.toCaseInsensitive( attrs ) ); } @@ -371,11 +375,13 @@ public void rebind( Name name, Object obj, Attributes attrs ) throws NamingException { LdapDN target = buildTarget( name ); + if ( getNexusProxy().hasEntry( new EntryOperationContext( target ) ) ) { getNexusProxy().delete( new DeleteOperationContext( target ) ); } - bind( name, obj, attrs ); + + bind( name, obj, AttributeUtils.toCaseInsensitive( attrs ) ); } @@ -385,7 +391,7 @@ */ public DirContext createSubcontext( String name, Attributes attrs ) throws NamingException { - return createSubcontext( new LdapDN( name ), attrs ); + return createSubcontext( new LdapDN( name ), AttributeUtils.toCaseInsensitive( attrs ) ); } @@ -403,6 +409,7 @@ LdapDN target = buildTarget( name ); Rdn rdn = target.getRdn( target.size() - 1 ); + attrs = AttributeUtils.toCaseInsensitive( attrs ); Attributes attributes = ( Attributes ) attrs.clone(); if ( rdn.size() == 1 ) @@ -490,7 +497,7 @@ * @see javax.naming.directory.DirContext#search(java.lang.String, * javax.naming.directory.Attributes) */ - public NamingEnumeration search( String name, Attributes matchingAttributes ) throws NamingException + public NamingEnumeration search( String name, Attributes matchingAttributes ) throws NamingException { return search( new LdapDN( name ), matchingAttributes, null ); } @@ -500,9 +507,9 @@ * @see javax.naming.directory.DirContext#search(javax.naming.Name, * javax.naming.directory.Attributes) */ - public NamingEnumeration search( Name name, Attributes matchingAttributes ) throws NamingException + public NamingEnumeration search( Name name, Attributes matchingAttributes ) throws NamingException { - return search( name, matchingAttributes, null ); + return search( name, AttributeUtils.toCaseInsensitive( matchingAttributes ), null ); } @@ -510,10 +517,10 @@ * @see javax.naming.directory.DirContext#search(java.lang.String, * javax.naming.directory.Attributes, java.lang.String[]) */ - public NamingEnumeration search( String name, Attributes matchingAttributes, String[] attributesToReturn ) + public NamingEnumeration search( String name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException { - return search( new LdapDN( name ), matchingAttributes, attributesToReturn ); + return search( new LdapDN( name ), AttributeUtils.toCaseInsensitive( matchingAttributes ), attributesToReturn ); } @@ -521,7 +528,7 @@ * @see javax.naming.directory.DirContext#search(javax.naming.Name, * javax.naming.directory.Attributes, java.lang.String[]) */ - public NamingEnumeration search( Name name, Attributes matchingAttributes, String[] attributesToReturn ) + public NamingEnumeration search( Name name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException { SearchControls ctls = new SearchControls(); @@ -534,7 +541,9 @@ } // If matchingAttributes is null/empty use a match for everything filter - if ( null == matchingAttributes || matchingAttributes.size() <= 0 ) + matchingAttributes = AttributeUtils.toCaseInsensitive( matchingAttributes ); + + if ( ( null == matchingAttributes ) || ( matchingAttributes.size() <= 0 ) ) { PresenceNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT ); return getNexusProxy().search( @@ -618,7 +627,7 @@ * @see javax.naming.directory.DirContext#search(java.lang.String, * java.lang.String, javax.naming.directory.SearchControls) */ - public NamingEnumeration search( String name, String filter, SearchControls cons ) throws NamingException + public NamingEnumeration search( String name, String filter, SearchControls cons ) throws NamingException { return search( new LdapDN( name ), filter, cons ); } @@ -635,7 +644,7 @@ * @return an enumeration over the SearchResults * @throws NamingException if there are problems performing the search */ - public NamingEnumeration search( Name name, ExprNode filter, SearchControls cons ) throws NamingException + public NamingEnumeration search( Name name, ExprNode filter, SearchControls cons ) throws NamingException { LdapDN target = buildTarget( name ); return getNexusProxy().search( @@ -647,7 +656,7 @@ * @see javax.naming.directory.DirContext#search(javax.naming.Name, * java.lang.String, javax.naming.directory.SearchControls) */ - public NamingEnumeration search( Name name, String filter, SearchControls cons ) throws NamingException + public NamingEnumeration search( Name name, String filter, SearchControls cons ) throws NamingException { ExprNode filterNode; LdapDN target = buildTarget( name ); @@ -680,7 +689,7 @@ * java.lang.String, java.lang.Object[], * javax.naming.directory.SearchControls) */ - public NamingEnumeration search( String name, String filterExpr, Object[] filterArgs, SearchControls cons ) + public NamingEnumeration search( String name, String filterExpr, Object[] filterArgs, SearchControls cons ) throws NamingException { return search( new LdapDN( name ), filterExpr, filterArgs, cons ); @@ -692,7 +701,7 @@ * java.lang.String, java.lang.Object[], * javax.naming.directory.SearchControls) */ - public NamingEnumeration search( Name name, String filterExpr, Object[] filterArgs, SearchControls cons ) + public NamingEnumeration search( Name name, String filterExpr, Object[] filterArgs, SearchControls cons ) throws NamingException { int start;