directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 21180 - in incubator/directory/snickers/trunk/ldap-ber-provider/src: java/org/apache/snickers/ldap java/org/apache/snickers/ldap/search test/org/apache/snickers/ldap/bind test/org/apache/snickers/ldap/search
Date Mon, 14 Jun 2004 03:08:36 GMT
Author: akarasulu
Date: Sun Jun 13 20:08:35 2004
New Revision: 21180

Added:
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/ApproxMatchRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/EqualityMatchRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/GreaterOrEqualRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/LessOrEqualRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/PresentRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchAnyRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchFinalRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchInitialRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchRule.java   (contents, props changed)
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/TerminateFilterStateRule.java   (contents, props changed)
Modified:
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/bind/BindResponseRuleTest.java
   incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java
Log:
Commit changes ...

 o added search request filter rules for equality match
 o added search request filter rules for presence match
 o added search request filter rules for greaterThan match
 o added search request filter rules for lessThan match
 o added search request filter rules for approximate match
   
To do ...

 o need to handle extensible match
 o and, or and not expressions



Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java	(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapDigesterFactory.java	Sun Jun 13 20:08:35 2004
@@ -18,6 +18,7 @@
 
 
 import org.apache.snickers.ber.digester.BERDigester ;
+import org.apache.snickers.ber.digester.TagTree;
 import org.apache.snickers.ber.primitives.UniversalTag ;
 import org.apache.snickers.ber.digester.rules.PrimitiveIntDecodeRule ;
 import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
@@ -110,7 +111,7 @@
         addModifyDnResponseRules( digester ) ;
         addModifyRequestRules( digester ) ;
         addModifyResponseRules( digester ) ;
-        adddeletes( digester ) ;
+        addSearchRequestRules( digester ) ;
         addSearchResponseDoneRules( digester ) ;
         addSearchResponseReferenceRules( digester ) ;
         addSearchResponseEntryRules( digester ) ;
@@ -119,7 +120,7 @@
     }
 
 
-    private void adddeletes( BERDigester digester )
+    private void addSearchRequestRules( BERDigester digester )
     {
         int[] pattern = new int[2];
 
@@ -147,14 +148,66 @@
         digester.addRule( pattern, new TypesOnlyRule() );
 
         pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag();
+        digester.addRule( pattern, new TerminateFilterStateRule() );
         digester.addRule( pattern, new RequestedAttributesStateChangeRule() );
 
-        pattern = new int[4] ;
-        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag() ;
+        pattern = new int[4];
+        pattern[0] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag();
         pattern[1] = LdapTag.SEARCH_REQUEST.getPrimitiveTag();
         pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag();
         pattern[3] = UniversalTag.OCTET_STRING.getPrimitiveTag();
         digester.addRule( pattern, new RequestedAttributesRule() );
+
+        pattern = new int[2];
+        pattern[0] = TagTree.WILDCARD;
+        pattern[1] = LdapTag.CONTEXT_SPECIFIC_TAG_7.getPrimitiveTag();
+        digester.addRule( pattern, new PresentRule() );
+
+        pattern = new int[3];
+        pattern[0] = TagTree.WILDCARD;
+        pattern[1] = LdapTag.CONTEXT_SPECIFIC_TAG_3.getPrimitiveTag();
+        pattern[2] = UniversalTag.OCTET_STRING.getPrimitiveTag();
+        digester.addRule( pattern, new EqualityMatchRule() );
+
+        //
+        // substring filter and helper rules
+        //
+
+        pattern[1] = LdapTag.CONTEXT_SPECIFIC_TAG_4.getPrimitiveTag();
+        digester.addRule( pattern, new Octets2StringRule() );
+        pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag();
+        digester.addRule( pattern, new SubstringMatchRule() );
+
+        pattern = new int[4];
+        pattern[0] = TagTree.WILDCARD;
+        pattern[1] = LdapTag.CONTEXT_SPECIFIC_TAG_4.getPrimitiveTag();
+        pattern[2] = UniversalTag.SEQUENCE_SEQUENCE_OF.getPrimitiveTag();
+        pattern[3] = LdapTag.CONTEXT_SPECIFIC_TAG_0.getPrimitiveTag();
+        digester.addRule( pattern, new SubstringMatchInitialRule() );
+
+        pattern[3] = LdapTag.CONTEXT_SPECIFIC_TAG_1.getPrimitiveTag();
+        digester.addRule( pattern, new SubstringMatchAnyRule() );
+
+        pattern[3] = LdapTag.CONTEXT_SPECIFIC_TAG_2.getPrimitiveTag();
+        digester.addRule( pattern, new SubstringMatchFinalRule() );
+
+        //
+        // end substring filter rules
+        //
+
+        pattern = new int[3];
+        pattern[0] = TagTree.WILDCARD;
+        pattern[1] = LdapTag.CONTEXT_SPECIFIC_TAG_5.getPrimitiveTag();
+        pattern[2] = UniversalTag.OCTET_STRING.getPrimitiveTag();
+        digester.addRule( pattern, new GreaterOrEqualRule() );
+
+        pattern[1] = LdapTag.CONTEXT_SPECIFIC_TAG_6.getPrimitiveTag();
+        digester.addRule( pattern, new LessOrEqualRule() );
+
+        pattern[1] = LdapTag.CONTEXT_SPECIFIC_TAG_8.getPrimitiveTag();
+        digester.addRule( pattern, new ApproxMatchRule() );
+
+
     }
 
 

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java	(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/LdapTag.java	Sun Jun 13 20:08:35 2004
@@ -201,13 +201,38 @@
             "EXTENDED_RESPONSE", EXTENDED_RESPONSE_TAG,
             EXTENDED_RESPONSE_ID ) ;
 
+
+    /** Context specific 6 tag */
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_8 =
+            new ContextSpecificTag( 8, true );
+
+    /** Context specific 6 tag */
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_7 =
+            new ContextSpecificTag( 7, true );
+
+    /** Context specific 6 tag */
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_6 =
+            new ContextSpecificTag( 6, true );
+
+    /** Context specific 5 tag */
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_5 =
+            new ContextSpecificTag( 5, true );
+
+    /** Context specific tag used for SearchRequest expr node greaterOrEqual*/
+    public static final ContextSpecificTag GREATER_OR_EQUAL_TAG =
+            CONTEXT_SPECIFIC_TAG_5;
+
+    /** Context specific 3 tag */
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_3 =
+            new ContextSpecificTag( 3, true ) ;
+
     /** Context specific tag used for LDAPResult referrals */
     public static final ContextSpecificTag REFERRAL_TAG =
-            new ContextSpecificTag( 3, true ) ;
+            CONTEXT_SPECIFIC_TAG_3 ;
 
     /** Context specific tag used for BindResponse serverSaslCreds */
     public static final ContextSpecificTag SERVER_SASL_CREDS_TAG =
-            new ContextSpecificTag( 7, true ) ;
+            CONTEXT_SPECIFIC_TAG_7 ;
 
     /** Context specific tag used for CONTEXT_SPECIFIC 0 */
     public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_0 =
@@ -217,10 +242,6 @@
     public static final ContextSpecificTag EXTENDED_REQUEST_NAME_TAG =
             CONTEXT_SPECIFIC_TAG_0 ;
 
-    /** Context specific tag used for ExtendedRequest request value */
-    public static final ContextSpecificTag EXTENDED_REQUEST_VALUE_TAG =
-            new ContextSpecificTag( 1, false ) ;
-
     /** Context specific tag used for ExtendedResponse responseName */
     public static final ContextSpecificTag EXTENDED_RESPONSE_NAME_TAG =
             new ContextSpecificTag( 10, false ) ;
@@ -233,6 +254,21 @@
     public static final ContextSpecificTag MODIFYDN_REQUEST_NEWSUP_TAG =
             CONTEXT_SPECIFIC_TAG_0 ;
 
+    /** Context specific tag used for Search request new superior dn */
+    public static final ContextSpecificTag SEARCH_REQUEST_EQUALITY_MATH_TAG =
+            CONTEXT_SPECIFIC_TAG_3 ;
+
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_4 =
+        new ContextSpecificTag( 4, true );
+
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_1 =
+            new ContextSpecificTag( 1, true ) ;
+
+    /** Context specific tag used for ExtendedRequest request value */
+    public static final ContextSpecificTag EXTENDED_REQUEST_VALUE_TAG =
+           CONTEXT_SPECIFIC_TAG_1;
+    public static final ContextSpecificTag CONTEXT_SPECIFIC_TAG_2 = 
+            new ContextSpecificTag( 2, true ) ;
 
 
     // -----------------------------------------------------------------------

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/ApproxMatchRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/ApproxMatchRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,157 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ber.TypeClass;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+import org.apache.snickers.ldap.LdapTag;
+
+import org.apache.ldap.common.filter.SimpleNode;
+
+
+/**
+ * Rule used to gather and push an equality match node onto the stack.  This
+ * rule is registered using a wild card pattern: [*, 0x83000000, 0x04000000 ].
+ * It does check that all patterns causing a firing have the starting pattern
+ * of a SearchRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class ApproxMatchRule extends PrimitiveOctetStringRule
+{
+    private boolean isEnabled = true ;
+    private String name = null ;
+    private String value = null ;
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        // check to see we are within limits - have the right number of tags
+        int tagCount = getDigester().getTagCount();
+        if ( tagCount < 4 )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        /*
+         * check to see that we're dealing within a search request - this is
+         * done by making sure the tag right above the bottom tag is equal
+         * to the SEARCH_REQUEST tag. If not we must disable this rule.
+         */
+        if ( getDigester().getTag( tagCount - 2 ) !=
+                LdapTag.SEARCH_REQUEST.getPrimitiveTag() )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        super.tag( id, isPrimitive, typeClass );
+
+        int ii = getDigester().getCount() - 2;
+        SearchRequestProcessing processing;
+        processing = ( SearchRequestProcessing ) getDigester().peek(ii);
+
+        if ( processing.getState() != processing.FILTER_STATE )
+        {
+            isEnabled = false ;
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( isEnabled )
+        {
+            super.length( length );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( isEnabled )
+        {
+            super.value( buf );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( ! isEnabled )
+        {
+            isEnabled = true ;
+            return ;
+        }
+
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()];
+            buf.get( octets );
+        }
+
+        if ( name == null && value == null )
+        {
+            name = new String( octets ) ;
+        }
+        else if ( name != null && value == null )
+        {
+            value = new String( octets ) ;
+
+
+            SimpleNode node;
+            node = new SimpleNode( name, value, SimpleNode.APPROXIMATE );
+            getDigester().push( node ) ;
+
+            name = null ;
+            value = null ;
+        }
+        else
+        {
+            throw new IllegalStateException( "name = " + name
+                    + " and value = " + value );
+        }
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/EqualityMatchRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/EqualityMatchRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,157 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ber.TypeClass;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+import org.apache.snickers.ldap.LdapTag;
+
+import org.apache.ldap.common.filter.SimpleNode;
+
+
+/**
+ * Rule used to gather and push an equality match node onto the stack.  This
+ * rule is registered using a wild card pattern: [*, 0x83000000, 0x04000000 ].
+ * It does check that all patterns causing a firing have the starting pattern
+ * of a SearchRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class EqualityMatchRule extends PrimitiveOctetStringRule
+{
+    private boolean isEnabled = true ;
+    private String name = null ;
+    private String value = null ;
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        // check to see we are within limits - have the right number of tags
+        int tagCount = getDigester().getTagCount();
+        if ( tagCount < 4 )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        /*
+         * check to see that we're dealing within a search request - this is
+         * done by making sure the tag right above the bottom tag is equal
+         * to the SEARCH_REQUEST tag. If not we must disable this rule.
+         */
+        if ( getDigester().getTag( tagCount - 2 ) !=
+                LdapTag.SEARCH_REQUEST.getPrimitiveTag() )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        super.tag( id, isPrimitive, typeClass );
+
+        int ii = getDigester().getCount() - 2;
+        SearchRequestProcessing processing;
+        processing = ( SearchRequestProcessing ) getDigester().peek(ii);
+
+        if ( processing.getState() != processing.FILTER_STATE )
+        {
+            isEnabled = false ;
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( isEnabled )
+        {
+            super.length( length );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( isEnabled )
+        {
+            super.value( buf );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( ! isEnabled )
+        {
+            isEnabled = true ;
+            return ;
+        }
+
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()];
+            buf.get( octets );
+        }
+
+        if ( name == null && value == null )
+        {
+            name = new String( octets ) ;
+        }
+        else if ( name != null && value == null )
+        {
+            value = new String( octets ) ;
+
+
+            SimpleNode node;
+            node = new SimpleNode( name, value, SimpleNode.EQUALITY );
+            getDigester().push( node ) ;
+
+            name = null ;
+            value = null ;
+        }
+        else
+        {
+            throw new IllegalStateException( "name = " + name
+                    + " and value = " + value );
+        }
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/GreaterOrEqualRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/GreaterOrEqualRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,136 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ber.TypeClass;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+
+import org.apache.ldap.common.filter.SimpleNode;
+
+
+/**
+ * Rule used to gather and push an equality match node onto the stack.  This
+ * rule is registered using a wild card pattern: [*, 0x83000000, 0x04000000 ].
+ * It does check that all patterns causing a firing have the starting pattern
+ * of a SearchRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class GreaterOrEqualRule extends PrimitiveOctetStringRule
+{
+    private boolean isEnabled = true ;
+    private String name = null ;
+    private String value = null ;
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        super.tag( id, isPrimitive, typeClass );
+
+        int ii = getDigester().getCount() - 2;
+        SearchRequestProcessing processing;
+        processing = ( SearchRequestProcessing ) getDigester().peek(ii);
+
+        if ( processing.getState() != processing.FILTER_STATE )
+        {
+            isEnabled = false ;
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( isEnabled )
+        {
+            super.length( length );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( isEnabled )
+        {
+            super.value( buf );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( ! isEnabled )
+        {
+            isEnabled = true ;
+            return ;
+        }
+
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()];
+            buf.get( octets );
+        }
+
+        if ( name == null && value == null )
+        {
+            name = new String( octets ) ;
+        }
+        else if ( name != null && value == null )
+        {
+            value = new String( octets ) ;
+
+
+            SimpleNode node;
+            node = new SimpleNode( name, value, SimpleNode.GREATEREQ );
+            getDigester().push( node ) ;
+
+            name = null ;
+            value = null ;
+        }
+        else
+        {
+            throw new IllegalStateException( "name = " + name
+                    + " and value = " + value );
+        }
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/LessOrEqualRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/LessOrEqualRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,136 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ber.TypeClass;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+
+import org.apache.ldap.common.filter.SimpleNode;
+
+
+/**
+ * Rule used to gather and push an equality match node onto the stack.  This
+ * rule is registered using a wild card pattern: [*, 0x83000000, 0x04000000 ].
+ * It does check that all patterns causing a firing have the starting pattern
+ * of a SearchRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class LessOrEqualRule extends PrimitiveOctetStringRule
+{
+    private boolean isEnabled = true ;
+    private String name = null ;
+    private String value = null ;
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        super.tag( id, isPrimitive, typeClass );
+
+        int ii = getDigester().getCount() - 2;
+        SearchRequestProcessing processing;
+        processing = ( SearchRequestProcessing ) getDigester().peek(ii);
+
+        if ( processing.getState() != processing.FILTER_STATE )
+        {
+            isEnabled = false ;
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( isEnabled )
+        {
+            super.length( length );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( isEnabled )
+        {
+            super.value( buf );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( ! isEnabled )
+        {
+            isEnabled = true ;
+            return ;
+        }
+
+        // pushes a ByteBuffer onto the stack
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()];
+            buf.get( octets );
+        }
+
+        if ( name == null && value == null )
+        {
+            name = new String( octets ) ;
+        }
+        else if ( name != null && value == null )
+        {
+            value = new String( octets ) ;
+
+
+            SimpleNode node;
+            node = new SimpleNode( name, value, SimpleNode.LESSEQ );
+            getDigester().push( node ) ;
+
+            name = null ;
+            value = null ;
+        }
+        else
+        {
+            throw new IllegalStateException( "name = " + name
+                    + " and value = " + value );
+        }
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/PresentRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/PresentRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,138 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ldap.LdapTag;
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+import org.apache.snickers.ber.TypeClass;
+
+import org.apache.ldap.common.filter.PresenceNode;
+
+
+/**
+ * Populates the baseObject field of the SearchRequest.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class PresentRule extends PrimitiveOctetStringRule
+{
+    private boolean isEnabled = true ;
+
+
+    public PresentRule()
+    {
+        super( LdapTag.CONTEXT_SPECIFIC_TAG_7 ) ;
+    }
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        // check to see we are within limits - have the right number of tags
+        int tagCount = getDigester().getTagCount();
+        if ( tagCount < 3 )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        /*
+         * check to see that we're dealing within a search request - this is
+         * done by making sure the tag right above the bottom tag is equal
+         * to the SEARCH_REQUEST tag. If not we must disable this rule.
+         */
+        if ( getDigester().getTag( tagCount - 2 ) !=
+                LdapTag.SEARCH_REQUEST.getPrimitiveTag() )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        super.tag( id, isPrimitive, typeClass );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( isEnabled )
+        {
+            super.length( length );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( isEnabled )
+        {
+            super.value( buf );
+        }
+    }
+
+
+    /**
+     * Allows the super method to push a ByteBuffer onto the top of the stack
+     * which contains the drained contents of the superclass' ByteAccumulator.
+     * This ByteBuffer is popped first then used to populate the credentials.
+     * There is no need to copy this buffer since it will not be used again
+     * by the ByteAccumulator of the superclass so we should be able to use
+     * the byte[] based backing store if one is present.  However it might
+     * have to be copied even then.  Situations requiring a copy are when the
+     * buffer has a limit less than the capacity or when there is no
+     * accessible array to the buffer.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( isEnabled )
+        {
+            // pushes a ByteBuffer onto the stack
+            super.finish() ;
+
+            // pop the ByteBuffer the super method pushed
+            ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+            byte[] octets = null ;
+            if ( buf.limit() == buf.capacity() && buf.hasArray() )
+            {
+                // use the backing store
+                octets = buf.array() ;
+            }
+            else
+            {
+                // copy because we don't have accessible array or data < array
+                octets = new byte[buf.remaining()];
+                buf.get( octets );
+            }
+
+            getDigester().push( new PresenceNode( new String( octets ) ) );
+        }
+
+        isEnabled = true ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchAnyRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchAnyRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,69 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+import org.apache.snickers.ldap.LdapTag;
+
+
+/**
+ * A helper rule used to build a Substring match fiter expression.  This rule
+ * accessess the top object on the object stack which it presumes is the rule
+ * it is helping: an instance of the SubstringMatchRule class.  It sets the
+ * initial string value using the setter on this rule.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class SubstringMatchAnyRule extends PrimitiveOctetStringRule
+{
+    public SubstringMatchAnyRule()
+    {
+        super( LdapTag.CONTEXT_SPECIFIC_TAG_1 );
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()] ;
+            buf.get( octets ) ;
+        }
+
+        SubstringMatchRule rule = ( SubstringMatchRule ) getDigester().peek() ;
+        rule.addAny( new String( octets ) );
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchFinalRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchFinalRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,70 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+import org.apache.snickers.ldap.LdapTag;
+
+
+/**
+ * A helper rule used to build a Substring match fiter expression.  This rule
+ * accessess the top object on the object stack which it presumes is the rule
+ * it is helping: an instance of the SubstringMatchRule class.  It sets the
+ * initial string value using the setter on this rule.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class SubstringMatchFinalRule extends PrimitiveOctetStringRule
+{
+    public SubstringMatchFinalRule()
+    {
+        super( LdapTag.CONTEXT_SPECIFIC_TAG_2 );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()] ;
+            buf.get( octets ) ;
+        }
+
+        SubstringMatchRule rule = ( SubstringMatchRule ) getDigester().peek() ;
+        rule.setFinalStr( new String( octets ) );
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchInitialRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchInitialRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,70 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule;
+import org.apache.snickers.ldap.LdapTag;
+
+
+/**
+ * A helper rule used to build a Substring match fiter expression.  This rule
+ * accessess the top object on the object stack which it presumes is the rule
+ * it is helping: an instance of the SubstringMatchRule class.  It sets the
+ * initial string value using the setter on this rule.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class SubstringMatchInitialRule extends PrimitiveOctetStringRule
+{
+    public SubstringMatchInitialRule()
+    {
+        super( LdapTag.CONTEXT_SPECIFIC_TAG_0 );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#finish()
+     */
+    public void finish()
+    {
+        super.finish() ;
+
+        // pop the ByteBuffer the super method pushed
+        ByteBuffer buf = ( ByteBuffer ) getDigester().pop() ;
+
+        byte[] octets = null ;
+        if ( buf.limit() == buf.capacity() && buf.hasArray() )
+        {
+            // use the backing store
+            octets = buf.array() ;
+        }
+        else
+        {
+            // copy because we don't have accessible array or data < array
+            octets = new byte[buf.remaining()] ;
+            buf.get( octets ) ;
+        }
+
+        SubstringMatchRule rule = ( SubstringMatchRule ) getDigester().peek() ;
+        rule.setInitial( new String( octets ) );
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/SubstringMatchRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,187 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import java.util.ArrayList;
+import java.nio.ByteBuffer;
+
+import org.apache.snickers.ldap.LdapTag;
+import org.apache.snickers.ber.TypeClass;
+import org.apache.snickers.ber.digester.AbstractRule;
+
+import org.apache.ldap.common.filter.SubstringNode;
+
+
+/**
+ * A rule used to collect and instantiate a substring filter expression.  This
+ * rule reacts with others because it itself is pushed onto the stack.
+ * Interfaces on the rule allow for the collection of substring filter
+ * parameters.
+ * <br/>
+ * The rule is registered with wild card pattern [*, 0x84000000, 0x10000000] on
+ * a search request rather than using [*, 0x84000000].  This is done to have
+ * more specific registration.  It excepts a String the attribute name or "type"
+ * according to the ASN.1 definition to be available on the stack deposited by
+ * a rule using the [*, 0x84000000, 0x04000000] pattern.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class SubstringMatchRule extends AbstractRule
+{
+    private boolean isEnabled = true;
+    /** the initial substring gotten from the stack */
+    private String type = null;
+    private String initialStr = null;
+    private String finalStr = null;
+    private ArrayList any = new ArrayList();
+
+
+    /*
+     * @see org.apache.snickers.ber.digester.Rule#tag(int, boolean,
+     * org.apache.snickers.ber.TypeClass)
+     */
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        // check to see we are within limits - have the right number of tags
+        int tagCount = getDigester().getTagCount();
+        if ( tagCount < 4 )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        /*
+         * check to see that we're dealing within a search request - this is
+         * done by making sure the tag right above the bottom tag is equal
+         * to the SEARCH_REQUEST tag. If not we must disable this rule.
+         */
+        if ( getDigester().getTag( tagCount - 2 ) !=
+                LdapTag.SEARCH_REQUEST.getPrimitiveTag() )
+        {
+            this.isEnabled = false;
+            return;
+        }
+
+        super.tag( id, isPrimitive, typeClass );
+
+        /*
+         * If enabled we need to pop the string deposited there from a helper
+         * rule next we push this rule onto the stack to be populated by other
+         * rules.
+         */
+        if ( isEnabled )
+        {
+            type = ( String ) getDigester().pop();
+            getDigester().push( this );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#length(int)
+     */
+    public void length( int length )
+    {
+        if ( isEnabled )
+        {
+            super.length( length );
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.snickers.ber.Rule#value(java.nio.ByteBuffer)
+     */
+    public void value( ByteBuffer buf )
+    {
+        if ( isEnabled )
+        {
+            super.value( buf );
+        }
+    }
+
+
+    /**
+     * Creates a SubstringNode using all the values that have been set by other
+     * helper rules and pushes the node onto the object stack.
+     *
+     * @see org.apache.snickers.ber.digester.Rule#finish()
+     */
+    public void finish()
+    {
+        if ( isEnabled )
+        {
+            super.finish();
+            SubstringNode node;
+            node = new SubstringNode( any, type, initialStr, finalStr );
+
+            if ( getDigester().peek() == this )
+            {
+                getDigester().pop();
+            }
+
+            getDigester().push( node );
+        }
+
+        type = null;
+        finalStr = null;
+        isEnabled = true;
+        initialStr = null;
+        any = new ArrayList();
+    }
+
+
+    // ------------------------------------------------------------------------
+    // Members called by other rules to populate the fields of this rule
+    // ------------------------------------------------------------------------
+
+
+    /**
+     * Sets the initial portion of the substring match expression.
+     *
+     * @param initialStr the initial String
+     */
+    public void setInitial( String initialStr )
+    {
+        this.initialStr = initialStr;
+    }
+
+
+    /**
+     * Sets the final portion of the substring match expression.
+     *
+     * @param finalStr the final String
+     */
+    public void setFinalStr( String finalStr )
+    {
+        this.finalStr = finalStr;
+    }
+
+
+    /**
+     * Adds middle any region String to the substring match expression.
+     *
+     * @param anyStr a middle any region String
+     */
+    public void addAny( String anyStr )
+    {
+        this.any.add( anyStr ) ;
+    }
+}

Added: incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/TerminateFilterStateRule.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/java/org/apache/snickers/ldap/search/TerminateFilterStateRule.java	Sun Jun 13 20:08:35 2004
@@ -0,0 +1,52 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.snickers.ldap.search;
+
+
+import org.apache.snickers.ber.TypeClass;
+import org.apache.ldap.common.filter.ExprNode;
+
+
+/**
+ * Used to terminate the filter processing state.  Registered before the
+ * attributes rules are registered to switch state.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ *         Project</a>
+ * @version $Rev$
+ */
+public class TerminateFilterStateRule extends BaseSearchRequestRule
+{
+    public TerminateFilterStateRule( )
+    {
+        super( 3 );
+    }
+
+
+    public void tag( int id, boolean isPrimitive, TypeClass typeClass )
+    {
+        super.tag( id, isPrimitive, typeClass );
+
+        if ( getProcessing().getState() == getProcessing().FILTER_STATE )
+        {
+            getRequest().setFilter( ( ExprNode ) getDigester().pop() );
+            getProcessing().next();
+        }
+
+        setEnabled( false );
+    }
+}

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/bind/BindResponseRuleTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/bind/BindResponseRuleTest.java	(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/bind/BindResponseRuleTest.java	Sun Jun 13 20:08:35 2004
@@ -17,28 +17,19 @@
 package org.apache.snickers.ldap.bind ;
 
 
-import java.util.Iterator ;
-import java.nio.ByteBuffer ;
+import java.util.Iterator;
 
-import junit.framework.TestCase ;
-
-import org.apache.snickers.ber.digester.BERDigester ;
-
-import org.apache.snickers.ber.* ;
-import org.apache.snickers.ber.primitives.UniversalTag;
-import org.apache.snickers.ber.digester.rules.PrimitiveIntDecodeRule ;
-import org.apache.snickers.ber.digester.rules.PrimitiveOctetStringRule ;
 import org.apache.snickers.ldap.testutils.RuleTestCase;
 import org.apache.snickers.ldap.testutils.TestUtils;
 
-import org.apache.ldap.common.message.* ;
-import org.apache.commons.codec.stateful.CallbackHistory ;
+import org.apache.ldap.common.message.*;
 
 
 /**
  * Tests the population of an LdapResult using a ResultRule.
  * 
- * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory
+ * Project</a>
  * @version $Rev$
  */
 public class BindResponseRuleTest extends RuleTestCase

Modified: incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java
==============================================================================
--- incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java	(original)
+++ incubator/directory/snickers/trunk/ldap-ber-provider/src/test/org/apache/snickers/ldap/search/SearchRequestTest.java	Sun Jun 13 20:08:35 2004
@@ -19,10 +19,10 @@
 
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.ArrayList;
 
 import org.apache.ldap.common.message.*;
-import org.apache.ldap.common.filter.ExprNode;
-import org.apache.ldap.common.filter.FilterParserImpl;
+import org.apache.ldap.common.filter.*;
 
 import org.apache.snickers.ldap.testutils.TestUtils;
 import org.apache.snickers.ldap.testutils.RuleTestCase;
@@ -38,9 +38,9 @@
 public class SearchRequestTest extends RuleTestCase
 {
     /**
-     * Tests an search request decode.
+     * Tests an search request decode with a simple equality match filter.
      */
-    public void testSearchRequest() throws Exception
+    public void testEqualityMatchFilter() throws Exception
     {
         SearchRequestImpl req = new SearchRequestImpl( 33 );
         req.setBase( "dc=example,dc=com" );
@@ -58,8 +58,7 @@
         FilterParserImpl parser = new FilterParserImpl();
         ExprNode node = null ;
         node = parser.parse(
-                "( & ( ou = Human Resources ) ( l = SunnyVale ) "
-                + " ( | ( uid = akarasulu ) ( ! ( uid = jbean ) ) ) )" );
+                "( ou = Human Resources ) " ) ;
         req.setFilter( node );
 
         System.out.println( "Generated SearchRequest for test:" );
@@ -85,7 +84,380 @@
             assertTrue( attributes.contains( list.next() ) );
         }
 
-        // control test should fail
+        // control test should not exist
         assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+        node = req.getFilter();
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        node = decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+    }
+
+
+    /**
+     * Tests an search request decode with a simple greaterOrEqual filter.
+     */
+    public void testGreaterOrEqualFilter() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl( 33 );
+        req.setBase( "dc=example,dc=com" );
+        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        req.setScope( ScopeEnum.BASEOBJECT );
+        req.setSizeLimit( 2 );
+        req.setTimeLimit( 3 );
+        req.setTypesOnly( true );
+
+        req.addAttribute( "attr0" );
+        req.addAttribute( "attr1" );
+        req.addAttribute( "attr2" );
+
+
+        req.setFilter( new SimpleNode( "age", "30", SimpleNode.GREATEREQ ) );
+
+        System.out.println( "Generated SearchRequest for test:" );
+        System.out.println( TestUtils.printTupleTree( req ) );
+
+        SearchRequest decoded = ( SearchRequest )
+                snickersDecode( snaccEncode( req ) );
+        assertNotNull( decoded );
+
+        // test that we have all the properties set
+        assertEquals( req.getBase(), decoded.getBase() );
+        assertEquals( req.getScope(), decoded.getScope() );
+        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+
+        // test that we have all the attributes
+        Iterator list = req.getAttributes().iterator();
+        Collection attributes = decoded.getAttributes();
+        while( list.hasNext() )
+        {
+            assertTrue( attributes.contains( list.next() ) );
+        }
+
+        // control test should not exist
+        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+        ExprNode node = req.getFilter();
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        node = decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+        System.out.println( buf1.toString() );
     }
+
+
+    /**
+     * Tests an search request decode with a simple lessOrEqual match
+     * filter.
+     */
+    public void testLessOrEqualFilter() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl( 33 );
+        req.setBase( "dc=example,dc=com" );
+        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        req.setScope( ScopeEnum.BASEOBJECT );
+        req.setSizeLimit( 2 );
+        req.setTimeLimit( 3 );
+        req.setTypesOnly( true );
+
+        req.addAttribute( "attr0" );
+        req.addAttribute( "attr1" );
+        req.addAttribute( "attr2" );
+
+        req.setFilter( new SimpleNode( "age", "30", SimpleNode.LESSEQ ) );
+
+        System.out.println( "Generated SearchRequest for test:" );
+        System.out.println( TestUtils.printTupleTree( req ) );
+
+        SearchRequest decoded = ( SearchRequest )
+                snickersDecode( snaccEncode( req ) );
+        assertNotNull( decoded );
+
+        // test that we have all the properties set
+        assertEquals( req.getBase(), decoded.getBase() );
+        assertEquals( req.getScope(), decoded.getScope() );
+        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+
+        // test that we have all the attributes
+        Iterator list = req.getAttributes().iterator();
+        Collection attributes = decoded.getAttributes();
+        while( list.hasNext() )
+        {
+            assertTrue( attributes.contains( list.next() ) );
+        }
+
+        // control test should not exist
+        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+        ExprNode node = req.getFilter();
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        node = decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+        System.out.println( buf1.toString() );
+    }
+
+
+    /**
+     * Tests an search request decode with a simple presence match filter.
+     */
+    public void testPresentFilter() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl( 33 );
+        req.setBase( "dc=example,dc=com" );
+        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        req.setScope( ScopeEnum.BASEOBJECT );
+        req.setSizeLimit( 2 );
+        req.setTimeLimit( 3 );
+        req.setTypesOnly( true );
+
+        req.addAttribute( "attr0" );
+        req.addAttribute( "attr1" );
+        req.addAttribute( "attr2" );
+
+
+        req.setFilter( new PresenceNode( "objectClass" ) );
+
+        System.out.println( "Generated SearchRequest for test:" );
+        System.out.println( TestUtils.printTupleTree( req ) );
+
+        SearchRequest decoded = ( SearchRequest )
+                snickersDecode( snaccEncode( req ) );
+        assertNotNull( decoded );
+
+        // test that we have all the properties set
+        assertEquals( req.getBase(), decoded.getBase() );
+        assertEquals( req.getScope(), decoded.getScope() );
+        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+
+        // test that we have all the attributes
+        Iterator list = req.getAttributes().iterator();
+        Collection attributes = decoded.getAttributes();
+        while( list.hasNext() )
+        {
+            assertTrue( attributes.contains( list.next() ) );
+        }
+
+        // control test should not exist
+        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+        ExprNode node = req.getFilter();
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        node = decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+        System.out.println( buf1.toString() );
+    }
+
+
+    /**
+     * Tests an search request decode with a simple approx match filter.
+     */
+    public void testApproxMatchFilter() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl( 33 );
+        req.setBase( "dc=example,dc=com" );
+        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        req.setScope( ScopeEnum.BASEOBJECT );
+        req.setSizeLimit( 2 );
+        req.setTimeLimit( 3 );
+        req.setTypesOnly( true );
+
+        req.addAttribute( "attr0" );
+        req.addAttribute( "attr1" );
+        req.addAttribute( "attr2" );
+
+
+        req.setFilter( new SimpleNode( "cn", "Alex Karasula",
+                SimpleNode.APPROXIMATE ) );
+
+        System.out.println( "Generated SearchRequest for test:" );
+        System.out.println( TestUtils.printTupleTree( req ) );
+
+        SearchRequest decoded = ( SearchRequest )
+                snickersDecode( snaccEncode( req ) );
+        assertNotNull( decoded );
+
+        // test that we have all the properties set
+        assertEquals( req.getBase(), decoded.getBase() );
+        assertEquals( req.getScope(), decoded.getScope() );
+        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+
+        // test that we have all the attributes
+        Iterator list = req.getAttributes().iterator();
+        Collection attributes = decoded.getAttributes();
+        while( list.hasNext() )
+        {
+            assertTrue( attributes.contains( list.next() ) );
+        }
+
+        // control test should not exist
+        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+        ExprNode node = req.getFilter();
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        node = decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+        System.out.println( buf1.toString() );
+    }
+
+
+    /**
+     * Tests an search request decode with a simple substring match filter.
+     */
+    public void testSubstringsFilter() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl( 33 );
+        req.setBase( "dc=example,dc=com" );
+        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        req.setScope( ScopeEnum.BASEOBJECT );
+        req.setSizeLimit( 2 );
+        req.setTimeLimit( 3 );
+        req.setTypesOnly( true );
+
+        req.addAttribute( "attr0" );
+        req.addAttribute( "attr1" );
+        req.addAttribute( "attr2" );
+
+        String any0 = "ijklm";
+        String any1 = "nopqrs";
+        ArrayList any = new ArrayList();
+        any.add( any0 );
+        any.add( any1 );
+        SubstringNode node = new SubstringNode( any, "cn", "abcdefgh", "wxyz" );
+
+        req.setFilter( node );
+
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        System.out.println( buf0.toString() );
+
+        System.out.println( "Generated SearchRequest for test:" );
+        System.out.println( TestUtils.printTupleTree( req ) );
+
+        SearchRequest decoded = ( SearchRequest )
+                snickersDecode( snaccEncode( req ) );
+        assertNotNull( decoded );
+
+        // test that we have all the properties set
+        assertEquals( req.getBase(), decoded.getBase() );
+        assertEquals( req.getScope(), decoded.getScope() );
+        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+
+        // test that we have all the attributes
+        Iterator list = req.getAttributes().iterator();
+        Collection attributes = decoded.getAttributes();
+        while( list.hasNext() )
+        {
+            assertTrue( attributes.contains( list.next() ) );
+        }
+
+        // control test should not exist
+        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+
+        node = ( SubstringNode ) decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        System.out.println( buf1.toString() );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+    }
+
+
+    /**
+     * Tests an search request decode with a simple greaterOrEqual match filter.
+     *
+    public void testSearchRequest7() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl( 33 );
+        req.setBase( "dc=example,dc=com" );
+        req.setDerefAliases( DerefAliasesEnum.DEREFFINDINGBASEOBJ );
+        req.setScope( ScopeEnum.BASEOBJECT );
+        req.setSizeLimit( 2 );
+        req.setTimeLimit( 3 );
+        req.setTypesOnly( true );
+
+        req.addAttribute( "attr0" );
+        req.addAttribute( "attr1" );
+        req.addAttribute( "attr2" );
+
+
+        FilterParserImpl parser = new FilterParserImpl();
+        ExprNode node = null ;
+        node = parser.parse(
+                "( age > 30 ) " ) ;
+                //"( & ( ou = Human Resources ) ( l = SunnyVale ) "
+                //+ " ( | ( uid = akarasulu ) ( ! ( uid = jbean ) ) ) )" );
+        req.setFilter( node );
+
+        System.out.println( "Generated SearchRequest for test:" );
+        System.out.println( TestUtils.printTupleTree( req ) );
+
+        SearchRequest decoded = ( SearchRequest )
+                snickersDecode( snaccEncode( req ) );
+        assertNotNull( decoded );
+
+        // test that we have all the properties set
+        assertEquals( req.getBase(), decoded.getBase() );
+        assertEquals( req.getScope(), decoded.getScope() );
+        assertEquals( req.getTypesOnly(), decoded.getTypesOnly() );
+        assertEquals( req.getTimeLimit(), decoded.getTimeLimit() );
+        assertEquals( req.getSizeLimit(), decoded.getSizeLimit() );
+        assertEquals( req.getDerefAliases(), decoded.getDerefAliases() );
+
+        // test that we have all the attributes
+        Iterator list = req.getAttributes().iterator();
+        Collection attributes = decoded.getAttributes();
+        while( list.hasNext() )
+        {
+            assertTrue( attributes.contains( list.next() ) );
+        }
+
+        // control test should not exist
+        assertFalse( attributes.contains( "(*&#$&#$*@#" ) );
+
+        // filter tests
+        node = req.getFilter();
+        StringBuffer buf0 = new StringBuffer();
+        node.printToBuffer( buf0 );
+        node = decoded.getFilter();
+        StringBuffer buf1 = new StringBuffer();
+        node.printToBuffer( buf1 );
+        assertEquals(buf0.toString(), buf1.toString()) ;
+        System.out.println( buf1.toString() );
+    }
+     */
 }

Mime
View raw message