directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r191029 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/FilterGrammar.java
Date Thu, 16 Jun 2005 23:11:34 GMT
Author: elecharny
Date: Thu Jun 16 16:11:33 2005
New Revision: 191029

URL: http://svn.apache.org/viewcvs?rev=191029&view=rev
Log:
Added the last transitions for the SubstringFilter grammar.

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=191029&r1=191028&r2=191029&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
Thu Jun 16 16:11:33 2005
@@ -783,7 +783,7 @@
 
         // Here we are dealing with substrings. LDAP grammar is not very explicit about
         // what is allowed (-- at least one must be present !!!), while RFC 2254 is
-        // really clear. So we will follow this RFC :
+        // really clear. But LDAP grammar is the one to follow...
         //
         // substring ::= attr "=" [AttributeValue] any [AttributeValue]
         // any       ::= "*" *(AttributeValue "*")
@@ -962,8 +962,8 @@
         //     -- at least one must be present
         //     substrings      SEQUENCE OF CHOICE { (Value)
         //          ...
-        // Nothing to do. Here, we may have two possibilities. We may have an "initial" value,
-        // or an "any" value
+        // Nothing to do. Here, we may have three possibilities. We may have an "initial"
value,
+        // or an "any" value, or a "final" value. Any other option is an error. 
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_VALUE][0x30] = new
GrammarTransition(
                 LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG,
null );
 
@@ -1023,7 +1023,7 @@
         //          ...
         // Store the initial value.
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_VALUE][0x80]
= new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_TAG,

+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_INITIAL_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG,

                 new GrammarAction( "Store substring filter initial Value" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -1061,9 +1061,8 @@
         //          any     [1] LDAPString, (Tag)
         //          ...
         // We had an 'initial' substring, and now we have an 'any' substring. Nothing to
do.
-        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_TAG][0x81] = new
GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_LENGTH,
null );
-
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG][0x81]
= new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_LENGTH,
null );
 
         // SubstringFilter ::= SEQUENCE {
         //     ...
@@ -1113,7 +1112,7 @@
         //          ...
         // Store the 'any' value. 
         super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_VALUE][0x81] =
new GrammarTransition(
-                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_VALUE_LOOP,

+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_VALUE, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG,

                 new GrammarAction( "Store substring filter any Value" )
                 {
                     public void action( IAsn1Container container ) throws DecoderException
@@ -1132,6 +1131,223 @@
                     }
                 });
                 
+        // SubstringFilter ::= SEQUENCE {
+        //     ...
+        //     -- at least one must be present
+        //     substrings      SEQUENCE OF CHOICE { 
+        //          ...
+        //			any       [1] LDAPString, 
+        //          final     [2] LDAPString, (Tag)
+        //     }
+        //
+        // We have an 'final' value after an 'any' value. Nothing to do.
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG][0x82]
= new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH,
null);
+
+        // SubstringFilter ::= SEQUENCE {
+        //     ...
+        //     -- at least one must be present
+        //     substrings      SEQUENCE OF CHOICE { 
+        //          ...
+        //          final     [2] LDAPString, (Tag)
+        //     }
+        //
+        // We have an 'final' value only. Nothing to do.
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0x82] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH,
null);
+
+        // SubstringFilter ::= SEQUENCE {
+        //     ...
+        //     -- at least one must be present
+        //     substrings      SEQUENCE OF CHOICE { 
+        //          initial [0] LDAPString,
+        //          final     [2] LDAPString, (Tag)
+        //     }
+        // We had an 'initial' substring, and now we have an 'final' substring. Nothing to
do.
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG][0x82]
= new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_ANY_OR_FINAL_TAG, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH,
null );
+
+        // SubstringFilter ::= SEQUENCE {
+        //     ...
+        //     -- at least one must be present
+        //     substrings      SEQUENCE OF CHOICE {
+        //          ...
+        //          final     [2] LDAPString, (Length)
+        // We have a "final" value. Check the length.
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH][0x82]
= new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_LENGTH, LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_VALUE,

+                new GrammarAction( "Init Substring Substring Final Filter" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+
+                        SubstringFilter currentFilter = (SubstringFilter)searchRequest.getCurrentFilter();
+                        
+                        // Check the length
+                        int newLength = currentFilter.getSubstringsLength() - tlv.getLength().getLength()
- tlv.getLength().getSize() -1; 
+                        
+                        if (newLength < 0) 
+                        {
+                            throw new DecoderException("The substring filter length is exceeded
by the 'finzl' length");
+                        }
+                        else
+                        {
+                            currentFilter.setSubstringsLength(newLength);
+                        }
+                        
+                    }
+                });
+
+        // SubstringFilter ::= SEQUENCE {
+        //     ...
+        //     -- at least one must be present
+        //     substrings      SEQUENCE OF CHOICE {
+        //          ...
+        //          final     [2] LDAPString, (Value)
+        // Store the initial value.
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_VALUE][0x82]
= new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_FINAL_VALUE, LdapStatesEnum.END_STATE,

+                new GrammarAction( "Store substring filter final 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.
+                        SubstringFilter substringFilter = (SubstringFilter)searchRequest.getCurrentFilter();
+                        substringFilter.setFinalSubstrings(LdapString.parse(tlv.getValue().getData()));
+                    }
+                });
+                
+        // SubstringFilter ::= SEQUENCE {
+        //     ...
+        //     -- at least one must be present
+        //     }
+        //
+        // Has we must have at least an initial, any or final value, every other value is
an error.
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA0] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA1] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA2] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA3] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA4] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA5] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA6] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0x87] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA8] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0xA9] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+        
+        super.transitions[LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG][0x30] =
new GrammarTransition(
+                LdapStatesEnum.FILTER_SUBSTRINGS_SUBSTRINGS_CHOICE_TAG, LdapStatesEnum.FILTER_TAG,

+                new GrammarAction( "Bad tag exception" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+                        throw new DecoderException("At least an 'initial', 'any' or 'final'
value must be found");
+                    }
+                });
+
     }
 
     //~ Methods ------------------------------------------------------------------------------------



Mime
View raw message