You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/08/27 09:08:03 UTC
svn commit: r437314 - in /directory/branches/apacheds/1.0:
core-unit/src/test/java/org/apache/directory/server/core/jndi/
core/src/main/java/org/apache/directory/server/core/jndi/
core/src/main/java/org/apache/directory/server/core/normalization/ core/...
Author: akarasulu
Date: Sun Aug 27 00:08:03 2006
New Revision: 437314
URL: http://svn.apache.org/viewvc?rev=437314&view=rev
Log:
Fix for DIRSERVER-169 and partially for DIRSERVER-715
Modified:
directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/DIRSERVER169ITest.java
directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/BinarySearchTest.java
Modified: directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/DIRSERVER169ITest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/DIRSERVER169ITest.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/DIRSERVER169ITest.java (original)
+++ directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/DIRSERVER169ITest.java Sun Aug 27 00:08:03 2006
@@ -106,12 +106,11 @@
/**
- * TODO re-enable this test after fixing binary attribute searches.
- * @throws Exception
+ * Search over binary attributes now should work via the core JNDI
+ * provider.
*/
public void testPasswordComparisonSucceeds() throws Exception
{
- /*
Hashtable env = configuration.toJndiEnvironment();
env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
env.put( Context.PROVIDER_URL, "ou=system" );
@@ -127,6 +126,5 @@
// We should have a match
assertTrue( results.hasMore() );
- */
}
}
Modified: directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java (original)
+++ directory/branches/apacheds/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchContextITest.java Sun Aug 27 00:08:03 2006
@@ -550,6 +550,50 @@
attrs.get( "creatorsName" ).get() );
}
+
+ /**
+ * Creation of required attributes of a person entry.
+ */
+ protected Attributes getPersonAttributes( String sn, String cn )
+ {
+ Attributes attributes = new BasicAttributes();
+ Attribute attribute = new BasicAttribute( "objectClass" );
+ attribute.add( "top" );
+ attribute.add( "person" );
+ attributes.put( attribute );
+ attributes.put( "cn", cn );
+ attributes.put( "sn", sn );
+
+ return attributes;
+ }
+
+
+ public void testBinaryAttributesInFilter() throws NamingException
+ {
+ byte[] certData = new byte[] { 0x34, 0x56, 0x4e, 0x5f };
+
+ // First let's add a some binary data representing a userCertificate
+ Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
+ attrs.put( "userCertificate", certData );
+ sysRoot.createSubcontext( "cn=Kate Bush", attrs );
+
+ // Search for kate by cn first
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+ NamingEnumeration enm = sysRoot.search( "", "(cn=Kate Bush)", controls );
+ assertTrue( enm.hasMore() );
+ SearchResult sr = ( SearchResult ) enm.next();
+ assertNotNull( sr );
+ assertFalse( enm.hasMore() );
+ assertEquals( "cn=Kate Bush,ou=system", sr.getName() );
+
+ enm = sysRoot.search( "", "(userCertificate={0})", new Object[] {certData}, controls );
+ assertTrue( enm.hasMore() );
+ sr = ( SearchResult ) enm.next();
+ assertNotNull( sr );
+ assertFalse( enm.hasMore() );
+ assertEquals( "cn=Kate Bush,ou=system", sr.getName() );
+ }
// this one is failing because it returns the admin user twice: count = 15
// public void testFilterExpansion3() throws Exception
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Sun Aug 27 00:08:03 2006
@@ -53,6 +53,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.StringTools;
/**
@@ -636,11 +637,27 @@
// Parse index
index = Integer.parseInt( buf.substring( start + 1, ii ) );
- /*
- * Replace the '{ i }' with the string representation of the value
- * held in the filterArgs array at index index.
- */
- buf.replace( start, ii + 1, filterArgs[index].toString() );
+ if ( filterArgs[index] instanceof String )
+ {
+ /*
+ * Replace the '{ i }' with the string representation of the value
+ * held in the filterArgs array at index index.
+ */
+ buf.replace( start, ii + 1, ( String ) filterArgs[index] );
+ }
+ else if ( filterArgs[index] instanceof byte[] )
+ {
+ String hexstr = "#" + StringTools.toHexString( ( byte[] ) filterArgs[index] );
+ buf.replace( start, ii + 1, hexstr );
+ }
+ else
+ {
+ /*
+ * Replace the '{ i }' with the string representation of the value
+ * held in the filterArgs array at index index.
+ */
+ buf.replace( start, ii + 1, filterArgs[index].toString() );
+ }
}
return search( name, buf.toString(), cons );
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java Sun Aug 27 00:08:03 2006
@@ -131,9 +131,24 @@
case( LeafNode.GREATEREQ ):
case( LeafNode.LESSEQ ):
SimpleNode simpleNode = ( SimpleNode ) leaf;
- newLeaf = new SimpleNode( descendant.getOid(),
- simpleNode.getValue(),
- simpleNode.getAssertionType() );
+ if ( simpleNode.getValue() instanceof String )
+ {
+ newLeaf = new SimpleNode( descendant.getOid(),
+ ( String ) simpleNode.getValue(),
+ simpleNode.getAssertionType() );
+ }
+ else if ( simpleNode.getValue() instanceof byte[] )
+ {
+ newLeaf = new SimpleNode( descendant.getOid(),
+ ( byte[] ) simpleNode.getValue(),
+ simpleNode.getAssertionType() );
+ }
+ else
+ {
+ newLeaf = new SimpleNode( descendant.getOid(),
+ simpleNode.getValue().toString(),
+ simpleNode.getAssertionType() );
+ }
break;
default:
throw new IllegalStateException( "Unknown assertion type: "
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java Sun Aug 27 00:08:03 2006
@@ -294,9 +294,24 @@
case( LeafNode.GREATEREQ ):
case( LeafNode.LESSEQ ):
SimpleNode simpleNode = ( SimpleNode ) leaf;
- newLeaf = new SimpleNode( descendant.getOid(),
- simpleNode.getValue(),
- simpleNode.getAssertionType() );
+ if ( simpleNode.getValue() instanceof String )
+ {
+ newLeaf = new SimpleNode( descendant.getOid(),
+ ( String ) simpleNode.getValue(),
+ simpleNode.getAssertionType() );
+ }
+ else if ( simpleNode.getValue() instanceof byte[] )
+ {
+ newLeaf = new SimpleNode( descendant.getOid(),
+ ( byte[] ) simpleNode.getValue(),
+ simpleNode.getAssertionType() );
+ }
+ else
+ {
+ newLeaf = new SimpleNode( descendant.getOid(),
+ simpleNode.getValue().toString(),
+ simpleNode.getAssertionType() );
+ }
break;
default:
throw new IllegalStateException( "Unknown assertion type: "
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/normalization/NormalizingVisitor.java Sun Aug 27 00:08:03 2006
@@ -101,7 +101,7 @@
if ( node instanceof SimpleNode )
{
SimpleNode snode = ( SimpleNode ) node;
- String normalized;
+ Object normalized;
try
{
@@ -113,11 +113,33 @@
}
else if ( Character.isDigit( snode.getAttribute().charAt( 0 ) ) )
{
- normalized = ncn.normalizeByOid( snode.getAttribute(), snode.getValue() );
+ if ( snode.getValue() instanceof String )
+ {
+ normalized = ncn.normalizeByOid( snode.getAttribute(), ( String ) snode.getValue() );
+ }
+ else if ( snode.getValue() instanceof byte [] )
+ {
+ normalized = ncn.normalizeByOid( snode.getAttribute(), ( byte[] ) snode.getValue() );
+ }
+ else
+ {
+ normalized = ncn.normalizeByOid( snode.getAttribute(), snode.getValue().toString() );
+ }
}
else
{
- normalized = ncn.normalizeByName( snode.getAttribute(), snode.getValue() );
+ if ( snode.getValue() instanceof String )
+ {
+ normalized = ncn.normalizeByName( snode.getAttribute(), ( String ) snode.getValue() );
+ }
+ else if ( snode.getValue() instanceof byte [] )
+ {
+ normalized = ncn.normalizeByName( snode.getAttribute(), ( byte[] ) snode.getValue() );
+ }
+ else
+ {
+ normalized = ncn.normalizeByName( snode.getAttribute(), snode.getValue().toString() );
+ }
}
}
catch ( NamingException e )
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java Sun Aug 27 00:08:03 2006
@@ -38,7 +38,9 @@
import org.apache.directory.shared.ldap.filter.ScopeNode;
import org.apache.directory.shared.ldap.filter.SimpleNode;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
import org.apache.directory.shared.ldap.schema.Normalizer;
import org.apache.directory.shared.ldap.util.AttributeUtils;
@@ -350,6 +352,12 @@
private Comparator getComparator( String attrId ) throws NamingException
{
MatchingRule mrule = getMatchingRule( attrId, EQUALITY_MATCH );
+
+ if ( mrule == null )
+ {
+ return ByteArrayComparator.INSTANCE;
+ }
+
return mrule.getComparator();
}
@@ -364,6 +372,12 @@
private Normalizer getNormalizer( String attrId ) throws NamingException
{
MatchingRule mrule = getMatchingRule( attrId, EQUALITY_MATCH );
+
+ if ( mrule == null )
+ {
+ return NoOpNormalizer.INSTANCE;
+ }
+
return mrule.getNormalizer();
}
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/ConcreteNameComponentNormalizer.java Sun Aug 27 00:08:03 2006
@@ -24,6 +24,8 @@
import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
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.Normalizer;
@@ -60,36 +62,36 @@
/**
* @see NameComponentNormalizer#normalizeByName(String, String)
*/
- public String normalizeByName( String name, String value ) throws NamingException
+ public Object normalizeByName( String name, String value ) throws NamingException
{
- return lookup( name ).normalize( value ).toString();
+ return lookup( name ).normalize( value );
}
/**
* @see NameComponentNormalizer#normalizeByName(String, String)
*/
- public String normalizeByName( String name, byte[] value ) throws NamingException
+ public Object normalizeByName( String name, byte[] value ) throws NamingException
{
- return lookup( name ).normalize( value ).toString();
+ return lookup( name ).normalize( value );
}
/**
* @see NameComponentNormalizer#normalizeByOid(String, String)
*/
- public String normalizeByOid( String oid, String value ) throws NamingException
+ public Object normalizeByOid( String oid, String value ) throws NamingException
{
- return lookup( oid ).normalize( value ).toString();
+ return lookup( oid ).normalize( value );
}
/**
* @see NameComponentNormalizer#normalizeByOid(String, String)
*/
- public String normalizeByOid( String oid, byte[] value ) throws NamingException
+ public Object normalizeByOid( String oid, byte[] value ) throws NamingException
{
- return lookup( oid ).normalize( value ).toString();
+ return lookup( oid ).normalize( value );
}
@@ -107,6 +109,13 @@
private Normalizer lookup( String id ) throws NamingException
{
AttributeType type = attributeRegistry.lookup( id );
+ MatchingRule mrule = type.getEquality();
+
+ if ( mrule == null )
+ {
+ return NoOpNormalizer.INSTANCE;
+ }
+
return type.getEquality().getNormalizer();
}
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Sun Aug 27 00:08:03 2006
@@ -205,10 +205,19 @@
if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE && filter instanceof SimpleNode )
{
SimpleNode node = ( SimpleNode ) filter;
+ String compareto = null;
+ if ( node.getValue() instanceof String )
+ {
+ compareto = ( String ) node.getValue();
+ }
+ else
+ {
+ compareto = node.getValue().toString();
+ }
// see if node attribute is objectClass
if ( node.getAttribute().equalsIgnoreCase( "2.5.4.0" )
- && node.getValue().equalsIgnoreCase( "subschema" ) && node.getAssertionType() == SimpleNode.EQUALITY )
+ && "subschema".equalsIgnoreCase( compareto ) && node.getAssertionType() == SimpleNode.EQUALITY )
{
// call.setBypass( true );
Attributes attrs = getSubschemaEntry( searchCtls.getReturningAttributes() );
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluator.java Sun Aug 27 00:08:03 2006
@@ -23,6 +23,7 @@
import org.apache.directory.server.core.schema.OidRegistry;
import org.apache.directory.shared.ldap.filter.LeafNode;
import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.util.StringTools;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
@@ -95,8 +96,20 @@
}
// If the filter value for the objectClass is an OID we need to resolve a name
- String value = node.getValue();
-
+ String value = null;
+ if ( node.getValue() instanceof String )
+ {
+ value = ( String ) node.getValue();
+ }
+ else if ( node.getValue() instanceof byte[] )
+ {
+ value = "#" + StringTools.toHexString( ( byte[] ) node.getValue() );
+ }
+ else
+ {
+ value = node.getValue().toString();
+ }
+
if ( Character.isDigit( value.charAt( 0 ) ) )
{
Iterator list = registry.getNameSet( value ).iterator();
Modified: directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/BinarySearchTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/BinarySearchTest.java?rev=437314&r1=437313&r2=437314&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/BinarySearchTest.java (original)
+++ directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/BinarySearchTest.java Sun Aug 27 00:08:03 2006
@@ -118,7 +118,16 @@
assertFalse( enm.hasMore() );
assertEquals( "cn=Kate Bush", sr.getName() );
+ // TODO enable this test here
+ // Failing here below this due to the frontend interpretting the byte[]
+ // as a String value. I see the value sent to the SearchHandler of the
+ // filter to be a String looking like: "[B@17210a5".
// enm = ctx.search( "", "(userCertificate={0})", new Object[] {certData}, controls );
+// assertTrue( enm.hasMore() );
+// sr = ( SearchResult ) enm.next();
+// assertNotNull( sr );
+// assertFalse( enm.hasMore() );
+// assertEquals( "cn=Kate Bush", sr.getName() );
}
}