directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r191275 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java
Date Sat, 18 Jun 2005 11:42:49 GMT
Author: elecharny
Date: Sat Jun 18 04:42:47 2005
New Revision: 191275

URL: http://svn.apache.org/viewcvs?rev=191275&view=rev
Log:
Added the last transition of the Filter grammar (Extensible filter). The searchRequest LdapMessage
has been completed !

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java?rev=191275&r1=191274&r2=191275&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java
Sat Jun 18 04:42:47 2005
@@ -24,18 +24,22 @@
 import org.apache.asn1.ber.grammar.GrammarTransition;
 import org.apache.asn1.ber.grammar.IGrammar;
 import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.ber.tlv.Value;
 import org.apache.asn1.ldap.codec.LdapMessageContainer;
 import org.apache.asn1.ldap.codec.primitives.LdapString;
+import org.apache.asn1.ldap.codec.utils.IntegerDecoder;
 import org.apache.asn1.ldap.pojo.AttributeValueAssertion;
 import org.apache.asn1.ldap.pojo.LdapMessage;
 import org.apache.asn1.ldap.pojo.SearchRequest;
-import org.apache.asn1.ldap.pojo.SubstringFilter;
 import org.apache.asn1.ldap.pojo.filters.AndFilter;
 import org.apache.asn1.ldap.pojo.filters.AttributeValueAssertionFilter;
+import org.apache.asn1.ldap.pojo.filters.ConnectorFilter;
+import org.apache.asn1.ldap.pojo.filters.ExtensibleMatchFilter;
 import org.apache.asn1.ldap.pojo.filters.Filter;
 import org.apache.asn1.ldap.pojo.filters.NotFilter;
 import org.apache.asn1.ldap.pojo.filters.OrFilter;
 import org.apache.asn1.ldap.pojo.filters.PresentFilter;
+import org.apache.asn1.ldap.pojo.filters.SubstringFilter;
 import org.apache.asn1.primitives.OctetString;
 import org.apache.asn1.util.MutableString;
 
@@ -213,7 +217,7 @@
 
         // Filter ::= CHOICE {
         //     ...
-        //     extensibleMatch [9] MatchingRuleAssertion } (Tag)
+        //     extensibleMatch [9] ExtensibleMatchFilter } (Tag)
         // Nothing to do
         super.transitions[LdapStatesEnum.FILTER_TAG][0xA9] = new GrammarTransition(
                 LdapStatesEnum.FILTER_TAG, LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_LENGTH,
null );
@@ -248,7 +252,7 @@
                             // this parent, then. We also have to check the length
                             // against the parent.
                             checkLength( currentFilter, tlv );
-                            currentFilter.addFilter(andFilter);
+                            ((ConnectorFilter)currentFilter).addFilter(andFilter);
                             andFilter.setParent( currentFilter );
                         }
                         else
@@ -311,7 +315,7 @@
                             // this parent, then. We also have to check the length
                             // against the parent.
                             checkLength( currentFilter, tlv );
-                            currentFilter.addFilter(orFilter);
+                            ((ConnectorFilter)currentFilter).addFilter(orFilter);
                             orFilter.setParent( currentFilter );
                         }
                         else
@@ -375,7 +379,7 @@
                             // this parent, then. We also have to check the length
                             // against the parent.
                             checkLength( currentFilter, tlv );
-                            currentFilter.addFilter(notFilter);
+                            ((ConnectorFilter)currentFilter).addFilter(notFilter);
                             notFilter.setParent( currentFilter );
                         }
                         else
@@ -704,27 +708,7 @@
         //     ...
         // nothing to do.
         super.transitions[LdapStatesEnum.FILTER_PRESENT_LENGTH][0x87] = new GrammarTransition(
-                LdapStatesEnum.FILTER_PRESENT_LENGTH, LdapStatesEnum.FILTER_PRESENT_VALUE,

-                /*new GrammarAction( "Check present filter length" )
-                {
-                    public void action( IAsn1Container container ) throws DecoderException
-                    {
-                        // We will check the length against the current filter
-                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
-                            container;
-                        LdapMessage      ldapMessage          =
-                            ldapMessageContainer.getLdapMessage();
-                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
-
-                        Filter     currentFilter =
-                            searchRequest.getCurrentFilter();
-                        
-                        TLV                  tlv = ldapMessageContainer.getCurrentTLV();
-
-                        checkLength( currentFilter, tlv );
-                        return;
-                    }
-                }*/ null);
+                LdapStatesEnum.FILTER_PRESENT_LENGTH, LdapStatesEnum.FILTER_PRESENT_VALUE,
null);
 
         // Filter ::= CHOICE {
         //     ...
@@ -756,7 +740,7 @@
                             // this parent, then. We also have to check the length
                             // against the parent.
                             checkLength( currentFilter, tlv );
-                            currentFilter.addFilter(presentFilter);
+                            ((ConnectorFilter)currentFilter).addFilter(presentFilter);
                             presentFilter.setParent( currentFilter );
                         }
                         else
@@ -820,7 +804,7 @@
                             // this parent, then. We also have to check the length
                             // against the parent.
                             checkLength( currentFilter, tlv );
-                            currentFilter.addFilter(substringFilter);
+                            ((ConnectorFilter)currentFilter).addFilter(substringFilter);
                             substringFilter.setParent( currentFilter );
                         }
                         else
@@ -851,8 +835,6 @@
         // Nothing to do.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_VALUE][0xA4] = new GrammarTransition(
                 LdapStatesEnum.FILTER_SUBSTRINGS_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_TYPE_TAG,
null);
-        /* );
-               */
 
         // SubstringFilter ::= SEQUENCE {
         //     type            AttributeDescription, (Tag)
@@ -1348,6 +1330,415 @@
                     }
                 });
 
+        // Here we are dealing with extensible matches 
+        //
+        // Filter ::= CHOICE {
+        //     ...
+        //     extensibleMatch [9] ExtensibleMatchFilter} (Length)
+        //
+        // Check the length
+        super.transitions[LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_LENGTH][0xA9] = new GrammarTransition(
+                LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_LENGTH, LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE,

+                new GrammarAction( "Init extensible match Filter" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+
+                        // We can allocate the ExtensibleMatch Filter
+                        Filter extensibleMatchFilter = new ExtensibleMatchFilter();
+                        
+                        // Get the parent, if any
+                        Filter currentFilter = searchRequest.getCurrentFilter();
+                        
+                        if (currentFilter != null)
+                        {
+                            // Ok, we have a parent. The new Filter will be added to
+                            // this parent, then. We also have to check the length
+                            // against the parent.
+                            checkLength( currentFilter, tlv );
+                            ((ConnectorFilter)currentFilter).addFilter(extensibleMatchFilter);
+                            extensibleMatchFilter.setParent( currentFilter );
+                        }
+                        else
+                        {
+                            // No parent. This Filter will become the root.
+                            // First, check the length to see if it does not exceed its parent
+                            // expected length. (If there is no parent, we have to check
the
+                            // length against the SearchRequest )
+                            checkLength( searchRequest, tlv );
+
+                            searchRequest.setCurrentFilter(extensibleMatchFilter);
+                            searchRequest.setFilter(extensibleMatchFilter);
+                            extensibleMatchFilter.setParent( searchRequest );
+                        }
+
+                        // As this is a new Constructed object, we have to init its length
+                        int expectedLength = tlv.getLength().getLength();
+
+                        extensibleMatchFilter.setExpectedLength( expectedLength );
+                        extensibleMatchFilter.setCurrentLength( 0 );
+                    }
+                } );
+
+        // Here we are dealing with extensible matches 
+        //
+        // Filter ::= CHOICE {
+        //     ...
+        //     extensibleMatch [9] MatchingRuleAssertion} (Value)
+        //
+        // Nothing to do
+        super.transitions[LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE][0xA9] = new GrammarTransition(
+                LdapStatesEnum.FILTER_EXTENSIBLE_MATCH_VALUE, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG,
null); 
+
+        // MatchingRuleAssertion ::= SEQUENCE { (Tag)
+        //          ...
+        // Nothing to do
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG][0x30] = new
GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_TAG, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_LENGTH,
null );
+
+        // MatchingRuleAssertion ::= SEQUENCE { (Length)
+        //          ...
+        // Check the length
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_LENGTH][0x30] = new
GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_LENGTH, LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_VALUE,

+                new GrammarAction( "Init matching rule assertion" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+                        
+                        // Get the parent
+                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        
+                        // Check the length
+                        checkLength(currentFilter, tlv);
+
+                        // As this is a new Constructed object, we have to init its length
+                        int expectedLength = tlv.getLength().getLength();
+
+                        currentFilter.setExpectedMatchingRuleLength( expectedLength );
+                    }
+                } );
+
+        // MatchingRuleAssertion ::= SEQUENCE { (Value)
+        //          ...
+        // Nothing to do. Two cases next : we may have a matching rule or a type.
+        // At least one of those two elements must be present.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_VALUE][0x30] = new
GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_ASSERTION_VALUE, LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG,
null);
+        
+        
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //          matchingRule    [1] MatchingRuleId OPTIONAL, (Tag)
+        //			...
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG][0x81] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_RULE_LENGTH,
null );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //          matchingRule    [1] MatchingRuleId OPTIONAL, (Length)
+        //			...
+        // Check the length
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_LENGTH][0x81] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_LENGTH, LdapStatesEnum.FILTER_MATCHING_RULE_VALUE,

+                new GrammarAction( "matching rule assertion length" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+                        
+                        // Get the parent
+                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        
+                        // Check the length
+                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
+                        int length = tlv.getSize();
+                        
+                        if (expectedLength < length)
+                        {
+                            throw new DecoderException("The matching rule length is larger
than expected");
+                        }
+                        else
+                        {
+                            currentFilter.setExpectedMatchingRuleLength(expectedLength -
length);
+                        }
+                    }
+                } );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //          matchingRule    [1] MatchingRuleId OPTIONAL, (Value)
+        //			...
+        // Store the matching rule value.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_VALUE][0x81] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_VALUE, LdapStatesEnum.FILTER_MATCHING_TYPE_OR_MATCH_VALUE_TAG,

+                new GrammarAction( "Store matching rule Value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                        container;
+                        LdapMessage      ldapMessage          =
+                        ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+
+                        // Store the value.
+                        ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        extensibleMatchFilter.setMatchingRule(LdapString.parse(tlv.getValue().getData()));
+                    }
+                });
+                
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //			(void)
+        //          type            [2] AttributeDescription OPTIONAL, (Tag)
+        //			...
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG][0x82] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH,
null );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //			matchingRule    [1] MatchingRuleId OPTIONAL,
+        //          type            [2] AttributeDescription OPTIONAL, (Tag)
+        //			...
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_TYPE_OR_MATCH_VALUE_TAG][0x82] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_RULE_OR_TYPE_TAG, LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH,
null );
+
+        // MatchingRuleAssertion ::= SEQUENCE {
+        //          ...
+        //          type            [2] AttributeDescription OPTIONAL, (Length)
+        //			...
+        // Check the length
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH][0x82] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_TYPE_LENGTH, LdapStatesEnum.FILTER_MATCHING_TYPE_VALUE,

+                new GrammarAction( "matching rule assertion length" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+                        
+                        // Get the parent
+                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        
+                        // Check the length
+                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
+                        int length = tlv.getSize();
+                        
+                        if (expectedLength < length)
+                        {
+                            throw new DecoderException("The matching rule length is larger
than expected");
+                        }
+                        else
+                        {
+                            currentFilter.setExpectedMatchingRuleLength(expectedLength -
length);
+                        }
+                    }
+                } );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //          ...
+        //          type            [2] AttributeDescription OPTIONAL, (Length)
+        //			...
+        // Store the matching type value.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_TYPE_VALUE][0x82] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_TYPE_VALUE, LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_TAG,

+                new GrammarAction( "Store matching type Value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                        container;
+                        LdapMessage      ldapMessage          =
+                        ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+
+                        // Store the value.
+                        ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        extensibleMatchFilter.setType(LdapString.parse(tlv.getValue().getData()));
+                    }
+                });
+                
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //			...
+        //          matchValue      [3] AssertionValue, (Tag)
+        //			...
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_TAG][0x83] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_TAG, LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_LENGTH,
null );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //			...
+        //          matchValue      [3] AssertionValue, (Length)
+        //			...
+        // Check the length
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_LENGTH][0x83] = new
GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_LENGTH, LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_VALUE,

+                new GrammarAction( "matching match value length" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+                        
+                        // Get the parent
+                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        
+                        // Check the length
+                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
+                        int length = tlv.getSize();
+                        
+                        if (expectedLength < length)
+                        {
+                            throw new DecoderException("The matching rule length is larger
than expected");
+                        }
+                        else
+                        {
+                            currentFilter.setExpectedMatchingRuleLength(expectedLength -
length);
+                        }
+                    }
+                } );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //          ...
+        //          matchValue      [3] AssertionValue, (Value)
+        //			...
+        // Store the matching type value.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_VALUE][0x83] = new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_MATCH_VALUE_VALUE, LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_OR_END_TAG,

+                new GrammarAction( "Store matching match value Value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                        container;
+                        LdapMessage      ldapMessage          =
+                        ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+
+                        // Store the value.
+                        ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        extensibleMatchFilter.setMatchValue(new OctetString( tlv.getValue().getData()));
+                    }
+                });
+                
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //			...
+        //          dnAttributes    [4] BOOLEAN DEFAULT FALSE } (Tag)
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_OR_END_TAG][0x84]
= new GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_OR_END_TAG, LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_LENGTH,
null );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //			...
+        //          dnAttributes    [4] BOOLEAN DEFAULT FALSE } (Length)
+        // Check the length
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_LENGTH][0x84] = new
GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_LENGTH, LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_VALUE,

+                new GrammarAction( "matching dnAttributes length" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+                        
+                        // Get the parent
+                        ExtensibleMatchFilter currentFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+                        
+                        // Check the length
+                        int expectedLength = currentFilter.getExpectedMatchingRuleLength();
+                        int length = tlv.getSize();
+                        
+                        if (expectedLength < length)
+                        {
+                            throw new DecoderException("The matching rule length is larger
than expected");
+                        }
+                        else
+                        {
+                            currentFilter.setExpectedMatchingRuleLength(expectedLength -
length);
+                        }
+                    }
+                } );
+
+        // MatchingRuleAssertion ::= SEQUENCE { 
+        //          ...
+        //          dnAttributes    [4] BOOLEAN DEFAULT FALSE } (Length)
+        // Store the matching type value.
+        super.transitions[LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_VALUE][0x84] = new
GrammarTransition(
+                LdapStatesEnum.FILTER_MATCHING_DN_ATTRIBUTES_VALUE, LdapStatesEnum.END_STATE,

+                new GrammarAction( "Store matching dnAttributes Value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                        container;
+                        LdapMessage      ldapMessage          =
+                        ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+
+                        // Store the value.
+                        ExtensibleMatchFilter extensibleMatchFilter = (ExtensibleMatchFilter)searchRequest.getCurrentFilter();
+
+                        // We get the value. If it's a 0, it's a FALSE. If it's
+                        // a FF, it's a TRUE. Any other value should be an error,
+                        // but we could relax this constraint. So if we have something
+                        // which is not 0, it will be interpreted as TRUE, but we
+                        // will generate a warning.
+                        Value value     = tlv.getValue();
+
+                        int  dnAttributes = IntegerDecoder.parse( value, 0, 255 );
+
+                        extensibleMatchFilter.setDnAttributes( dnAttributes != 0 );
+
+                        if ( ( dnAttributes != 0 ) && (dnAttributes != 255 ) ) 
+                        {
+                            log.warn("A boolean must be encoded with a 0x00 or a 0xFF value");
+                        }
+                        
+                    }
+                });
+                
     }
 
     //~ Methods ------------------------------------------------------------------------------------
@@ -1442,7 +1833,7 @@
             // this parent, then. We also have to check the length
             // against the parent.
             checkLength( currentFilter, tlv );
-            currentFilter.addFilter(filter);
+            ((ConnectorFilter)currentFilter).addFilter(filter);
             filter.setParent( currentFilter );
         }
         else



Mime
View raw message