directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r355241 - /directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java
Date Thu, 08 Dec 2005 22:16:01 GMT
Author: elecharny
Date: Thu Dec  8 14:15:56 2005
New Revision: 355241

URL: http://svn.apache.org/viewcvs?rev=355241&view=rev
Log:
Fixed the buggy compare operation, which was only working 
for Strings, not for byte[]

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java?rev=355241&r1=355240&r2=355241&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/DefaultDirectoryPartitionNexus.java
Thu Dec  8 14:15:56 2005
@@ -18,6 +18,7 @@
 
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -40,6 +41,7 @@
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 
+import org.apache.asn1.codec.util.StringUtils;
 import org.apache.ldap.common.MultiException;
 import org.apache.ldap.common.NotImplementedException;
 import org.apache.ldap.common.schema.AttributeType;
@@ -363,14 +365,34 @@
          * through all values looking for a match.
          */
         Normalizer normalizer = attrType.getEquality().getNormalizer();
-        String reqVal = ( String ) normalizer.normalize( value );
+        Object reqVal = normalizer.normalize( value );
+        
         for ( int ii = 0; ii < attr.size(); ii++ )
         {
-            String attrVal = ( String ) normalizer.normalize( attr.get( ii ) );
-            if ( attrVal.equals( reqVal ) )
-            {
-                return true;
-            }
+        	Object attrValObj = normalizer.normalize( attr.get( ii ) );
+        	
+        	if ( attrValObj instanceof String )
+        	{
+        		String attrVal = ( String ) attrValObj;
+        		
+	            if ( ( reqVal instanceof String) && attrVal.equals( reqVal ) )
+	            {
+	                return true;
+	            }
+        	}
+        	else
+        	{
+        		byte[] attrVal = (byte[])attrValObj;
+        		
+        		if ( reqVal instanceof byte[] ) 
+        		{
+        			return Arrays.equals( attrVal, (byte[])reqVal );
+        		}
+        		else if ( reqVal instanceof String )
+        		{
+        			return Arrays.equals( attrVal, StringUtils.getBytesUtf8( (String)reqVal ) );
+        		}
+        	}
         }
 
         return false;



Mime
View raw message