You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/09/27 15:57:16 UTC
svn commit: r291939 - in
/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar:
AbandonRequestGrammar.java AddRequestGrammar.java AddResponseGrammar.java
BindRequestGrammar.java
Author: elecharny
Date: Tue Sep 27 06:57:08 2005
New Revision: 291939
URL: http://svn.apache.org/viewcvs?rev=291939&view=rev
Log:
- added logs
- changed the way Strings are stored
Modified:
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java
directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java?rev=291939&r1=291938&r2=291939&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java Tue Sep 27 06:57:08 2005
@@ -25,6 +25,8 @@
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.ber.tlv.Value;
import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.util.IntegerDecoderException;
+import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.pojo.AbandonRequest;
@@ -99,15 +101,10 @@
Value value = tlv.getValue();
- int abandonnedMessageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
-
- if ( ( abandonnedMessageId < 0 ) || ( abandonnedMessageId > Integer.MAX_VALUE ) )
- {
- throw new DecoderException(
- "The message ID must be between (0 .. 2 147 483 647)" );
- }
- else
+ try
{
+ int abandonnedMessageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
+
// Ok, the Message ID is correct. We have to store it
// in the AbandonRequest object
@@ -115,8 +112,20 @@
AbandonRequest abandonRequest = new AbandonRequest();
abandonRequest.setAbandonedMessageId( abandonnedMessageId );
ldapMessage.setProtocolOP( abandonRequest );
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "AbandonMessage Id has been decoded : " + abandonnedMessageId );
+ }
return;
+ }
+ catch ( IntegerDecoderException ide )
+ {
+ log.error("The Abandonned Message Id " + StringUtils.dumpBytes( value.getData() ) +
+ " is invalid : " + ide.getMessage() + ". The message ID must be between (0 .. 2 147 483 647)" );
+
+ throw new DecoderException( ide.getMessage() );
}
}
} );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java?rev=291939&r1=291938&r2=291939&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java Tue Sep 27 06:57:08 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import java.io.UnsupportedEncodingException;
+
import javax.naming.InvalidNameException;
import org.apache.asn1.codec.DecoderException;
@@ -27,6 +29,7 @@
import org.apache.asn1new.ber.tlv.TLV;
import org.apache.asn1new.ber.tlv.UniversalTag;
import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.util.StringUtils;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.codec.primitives.LdapDN;
@@ -138,6 +141,7 @@
}
catch ( InvalidNameException ine )
{
+ log.error( "The DN is invalid : " + StringUtils.dumpBytes(tlv.getValue().getData()) + " : " + ine.getMessage() );
throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
}
}
@@ -235,12 +239,21 @@
// Store the type. It can't be null.
if ( tlv.getLength().getLength() == 0 )
{
+ log.error( "Null types are not allowed" );
throw new DecoderException( "The type can't be null" );
}
else
{
- addRequest.addAttributeType( new LdapString(
- tlv.getValue().getData() ) );
+ try
+ {
+ addRequest.addAttributeType( new LdapString(
+ tlv.getValue().getData() ) );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ log.error( "The type is invalid : " + StringUtils.dumpBytes( tlv.getValue().getData() ) + " : " + uee.getMessage() );
+ throw new DecoderException( "Invalid attribute type : " + uee.getMessage() );
+ }
}
}
} );
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java?rev=291939&r1=291938&r2=291939&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java Tue Sep 27 06:57:08 2005
@@ -28,8 +28,6 @@
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
import org.apache.asn1new.ldap.pojo.AddResponse;
import org.apache.asn1new.ldap.pojo.LdapMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
@@ -41,9 +39,6 @@
public class AddResponseGrammar extends AbstractGrammar implements IGrammar
{
//~ Static fields/initializers -----------------------------------------------------------------
-
- /** The logger */
- private static final Logger log = LoggerFactory.getLogger( AddResponseGrammar.class );
/** The instance of grammar. AddResponseGrammar is a singleton */
private static IGrammar instance = new AddResponseGrammar();
Modified: directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java?rev=291939&r1=291938&r2=291939&view=diff
==============================================================================
--- directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java (original)
+++ directory/shared/ldap/branches/shared-ldap-NameComponent/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java Tue Sep 27 06:57:08 2005
@@ -16,6 +16,8 @@
*/
package org.apache.asn1new.ldap.codec.grammar;
+import java.io.UnsupportedEncodingException;
+
import javax.naming.InvalidNameException;
import org.apache.asn1.codec.DecoderException;
@@ -28,6 +30,8 @@
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.StringUtils;
import org.apache.asn1new.primitives.OctetString;
import org.apache.asn1new.ldap.codec.LdapConstants;
import org.apache.asn1new.ldap.codec.LdapMessageContainer;
@@ -140,9 +144,31 @@
Value value = tlv.getValue();
- int version = IntegerDecoder.parse( value, 1, 127 );
-
- bindRequestMessage.setVersion( version );
+ try
+ {
+ int version = IntegerDecoder.parse( value, 1, 127 );
+
+ if ( version != 3 )
+ {
+ log.error("The version " + version + " is invalid : it must be 3" );
+
+ throw new DecoderException( "Ldap Version " + version + " is not supported" );
+ }
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "Ldap version " + version );
+ }
+
+ bindRequestMessage.setVersion( version );
+ }
+ catch ( IntegerDecoderException ide )
+ {
+ log.error("The version " + StringUtils.dumpBytes( value.getData() ) +
+ " is invalid : " + ide.getMessage() + ". The version must be between (0 .. 127)" );
+
+ throw new DecoderException( ide.getMessage() );
+ }
return;
}
@@ -186,10 +212,16 @@
}
catch ( InvalidNameException ine )
{
+ log.error( "Incorrect DN given : " + StringUtils.dumpBytes( tlv.getValue().getData() ) + " : " + ine.getMessage() );
throw new DecoderException( "Incorrect DN given : " + ine.getMessage() );
}
}
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( " The Bind name is " + bindRequestMessage.getName() );
+ }
+
return;
}
} );
@@ -242,6 +274,11 @@
{
authentication.setSimple( new OctetString( tlv.getValue().getData() ) );
}
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "The simple authentication is : " + authentication.getSimple() );
+ }
}
} );
@@ -297,7 +334,20 @@
}
else
{
- authentication.setMechanism( new LdapString(tlv.getValue().getData() ) );
+ try
+ {
+ authentication.setMechanism( new LdapString(tlv.getValue().getData() ) );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ log.error( "Invalid mechanism : " + StringUtils.dumpBytes( tlv.getValue().getData() ) + " : " + uee.getMessage() );
+ throw new DecoderException( uee.getMessage() );
+ }
+ }
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "The mechanism is : " + authentication.getMechanism() );
}
return;
@@ -363,6 +413,11 @@
else
{
credentials.setCredentials( new OctetString( tlv.getValue().getData() ) );
+ }
+
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( "The credentials are : " + credentials.getCredentials() );
}
return;