directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r312977 - in /directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar: FilterGrammar.java LdapControlGrammar.java ModifyDNRequestGrammar.java SearchRequestGrammar.java
Date Tue, 11 Oct 2005 23:25:30 GMT
Author: elecharny
Date: Tue Oct 11 16:25:22 2005
New Revision: 312977

URL: http://svn.apache.org/viewcvs?rev=312977&view=rev
Log:
* fixed a bug in ModifyDNRequestGrammr : an IntegerDecoder was used instead of a BooleanDecoder
* added the catch of BooleanDecoderException which has been added to the asn1-new-codec lib

Modified:
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
    directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java?rev=312977&r1=312976&r2=312977&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
Tue Oct 11 16:25:22 2005
@@ -26,6 +26,7 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.BooleanDecoder;
+import org.apache.asn1new.util.BooleanDecoderException;
 import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.primitives.OctetString;
 import org.apache.asn1new.ldap.codec.LdapConstants;
@@ -1230,7 +1231,22 @@
                         // will generate a warning.
                         Value value     = tlv.getValue();
 
-                        extensibleMatchFilter.setDnAttributes( BooleanDecoder.parse( value
) );
+                        try
+                        {
+                            extensibleMatchFilter.setDnAttributes( BooleanDecoder.parse(
value ) );
+                        }
+                        catch ( BooleanDecoderException bde )
+                        {
+                            log.error("The DN attributes flag " + StringUtils.dumpBytes(
value.getData() ) + 
+                                    " is invalid : " + bde.getMessage() + ". It should be
0 or 255" );
+                        
+                            throw new DecoderException( bde.getMessage() );
+                        }
+                            
+                        if ( log.isDebugEnabled() )
+                        {
+                            log.debug( "DN Attributes : " + extensibleMatchFilter.isDnAttributes()
);
+                        }
                     }
                 });
                 

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java?rev=312977&r1=312976&r2=312977&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
Tue Oct 11 16:25:22 2005
@@ -26,6 +26,7 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.BooleanDecoder;
+import org.apache.asn1new.util.BooleanDecoderException;
 import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.primitives.OID;
 import org.apache.asn1new.primitives.OctetString;
@@ -238,7 +239,17 @@
                         // will generate a warning.
                         Value value        = tlv.getValue();
 
-                        control.setCriticality( BooleanDecoder.parse( value) );
+                        try
+                        {
+                            control.setCriticality( BooleanDecoder.parse( value) );
+                        }
+                        catch ( BooleanDecoderException bde )
+                        {
+                            log.error("The control criticality flag " + StringUtils.dumpBytes(
value.getData() ) + 
+                                    " is invalid : " + bde.getMessage() + ". It should be
0 or 255" );
+                        
+                            throw new DecoderException( bde.getMessage() );
+                        }
                         
                         if ( log.isDebugEnabled() )
                         {

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java?rev=312977&r1=312976&r2=312977&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
Tue Oct 11 16:25:22 2005
@@ -27,8 +27,8 @@
 import org.apache.asn1new.ber.tlv.TLV;
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
-import org.apache.asn1new.util.IntegerDecoder;
-import org.apache.asn1new.util.IntegerDecoderException;
+import org.apache.asn1new.util.BooleanDecoder;
+import org.apache.asn1new.util.BooleanDecoderException;
 import org.apache.asn1new.util.StringUtils;
 import org.apache.asn1new.ldap.codec.LdapConstants;
 import org.apache.asn1new.ldap.codec.LdapMessageContainer;
@@ -264,30 +264,22 @@
                         // which is not 0, it will be interpreted as TRUE, but we
                         // will generate a warning.
                         Value value        = tlv.getValue();
-                        int   deleteOldRDN = 0;
 
                         try
                         {
-                            deleteOldRDN = IntegerDecoder.parse( value, 0, 255 );
+                            modifyDNRequest.setDeleteOldRDN( BooleanDecoder.parse( value
) );
                         }
-                        catch ( IntegerDecoderException ide )
+                        catch ( BooleanDecoderException bde )
                         {
                             log.error("The oldRDN flag " + StringUtils.dumpBytes( value.getData()
) + 
-                                    " is invalid : " + ide.getMessage() + ". It should be
0 or 255" );
+                                    " is invalid : " + bde.getMessage() + ". It should be
0 or 255" );
                         
-                            throw new DecoderException( ide.getMessage() );
-                        }
-
-                        modifyDNRequest.setDeleteOldRDN( deleteOldRDN != 0 );
-
-                        if ( ( deleteOldRDN != 0 ) && ( deleteOldRDN != 255 ) )
-                        {
-                            log.warn( "A boolean must be encoded with a 0x00 or a 0xFF value"
);
+                            throw new DecoderException( bde.getMessage() );
                         }
 
                         if ( log.isDebugEnabled() )
                         {
-                            if ( deleteOldRDN == 0 )
+                            if ( modifyDNRequest.isDeleteOldRDN() )
                             {
                                 log.debug( " Old RDN attributes will be deleted" );
                             }

Modified: directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java?rev=312977&r1=312976&r2=312977&view=diff
==============================================================================
--- directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
(original)
+++ directory/shared/ldap/trunk/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
Tue Oct 11 16:25:22 2005
@@ -28,6 +28,7 @@
 import org.apache.asn1new.ber.tlv.UniversalTag;
 import org.apache.asn1new.ber.tlv.Value;
 import org.apache.asn1new.util.BooleanDecoder;
+import org.apache.asn1new.util.BooleanDecoderException;
 import org.apache.asn1new.util.IntegerDecoder;
 import org.apache.asn1new.util.IntegerDecoderException;
 import org.apache.asn1new.util.StringUtils;
@@ -466,7 +467,17 @@
                         // will generate a warning.
                         Value value     = tlv.getValue();
 
-                        searchRequest.setTypesOnly( BooleanDecoder.parse( value ) );
+                        try
+                        {
+                            searchRequest.setTypesOnly( BooleanDecoder.parse( value ) );
+                        }
+                        catch ( BooleanDecoderException bde )
+                        {
+                            log.error("The types only flag " + StringUtils.dumpBytes( value.getData()
) + 
+                                    " is invalid : " + bde.getMessage() + ". It should be
0 or 255" );
+                        
+                            throw new DecoderException( bde.getMessage() );
+                        }
 
                         if ( log.isDebugEnabled() )
                         {
@@ -627,7 +638,7 @@
         //    ...
         // We have to create an array of elements to store the list of attributes
         // to retrieve. We don't know yet how many attributes we will read so we
-        // will allocate an ArrayList.
+        // will allocate an ArrayList. We also can have an empty list.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE][UniversalTag.SEQUENCE_TAG]
=
             new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE,
                 LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG,



Mime
View raw message