Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Tue Oct 3 06:49:43 2006 @@ -66,8 +66,6 @@ import org.apache.directory.shared.ldap.codec.search.SubstringFilter; import org.apache.directory.shared.ldap.codec.search.controls.PSearchControl; import org.apache.directory.shared.ldap.codec.search.controls.SubEntryControl; -import org.apache.directory.shared.ldap.codec.util.LdapString; -import org.apache.directory.shared.ldap.codec.util.LdapStringEncodingException; import org.apache.directory.shared.ldap.codec.util.LdapURL; import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException; import org.apache.directory.shared.ldap.filter.AbstractExprNode; @@ -109,7 +107,6 @@ import org.apache.directory.shared.ldap.message.SubentriesControl; import org.apache.directory.shared.ldap.message.UnbindRequestImpl; import org.apache.directory.shared.ldap.message.extended.GracefulShutdownRequest; -import org.apache.directory.shared.ldap.message.extended.StoredProcedureRequest; import org.apache.directory.shared.ldap.message.spi.Provider; import org.apache.directory.shared.ldap.message.spi.TransformerSpi; import org.slf4j.Logger; @@ -137,8 +134,7 @@ /** * Creates a passthrough transformer that really does nothing at all. * - * @param provider - * the povider for this transformer + * @param provider the provider for this transformer */ public TwixTransformer(Provider provider) { @@ -161,10 +157,8 @@ * Transform an AbandonRequest message from a TwixMessage to a * SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers AbandonRequestImpl */ private Message transformAbandonRequest( LdapMessage twixMessage, int messageId ) @@ -182,10 +176,8 @@ /** * Transform an AddRequest message from a TwixMessage to a SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers AddRequestImpl */ private Message transformAddRequest( LdapMessage twixMessage, int messageId ) @@ -206,10 +198,8 @@ /** * Transform a BindRequest message from a TwixMessage to a SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers BindRequestImpl */ private Message transformBindRequest( LdapMessage twixMessage, int messageId ) @@ -249,10 +239,8 @@ * Transform a CompareRequest message from a TwixMessage to a * SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers CompareRequestImpl */ private Message transformCompareRequest( LdapMessage twixMessage, int messageId ) @@ -283,10 +271,8 @@ /** * Transform a DelRequest message from a TwixMessage to a SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers DeleteRequestImpl */ private Message transformDelRequest( LdapMessage twixMessage, int messageId ) @@ -305,10 +291,8 @@ * Transform an ExtendedRequest message from a TwixMessage to a * SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers ExtendedRequestImpl */ private Message transformExtendedRequest( LdapMessage twixMessage, int messageId ) @@ -320,10 +304,6 @@ { snickersMessage = new GracefulShutdownRequest( messageId ); } - else if ( extendedRequest.getRequestName().equals( StoredProcedureRequest.EXTENSION_OID ) ) - { - snickersMessage = new StoredProcedureRequest( messageId ); - } else { snickersMessage = new ExtendedRequestImpl( messageId ); @@ -343,10 +323,8 @@ * Transform a ModifyDNRequest message from a TwixMessage to a * SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers ModifyDNRequestImpl */ private Message transformModifyDNRequest( LdapMessage twixMessage, int messageId ) @@ -373,10 +351,8 @@ /** * Transform a ModifyRequest message from a TwixMessage to a SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers ModifyRequestImpl */ private Message transformModifyRequest( LdapMessage twixMessage, int messageId ) @@ -406,8 +382,7 @@ /** * Transform the Filter part of a SearchRequest to en ExprNode * - * @param twixFilter - * The filter to be transformed + * @param twixFilter The filter to be transformed * @return An ExprNode */ private ExprNode transformFilter( Filter twixFilter ) @@ -476,7 +451,7 @@ (byte[])ava.getAssertionValue(), AbstractExprNode.EQUALITY ); } - + break; case LdapConstants.GREATER_OR_EQUAL_FILTER: @@ -610,10 +585,8 @@ /** * Transform a SearchRequest message from a TwixMessage to a SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers SearchRequestImpl */ private Message transformSearchRequest( LdapMessage twixMessage, int messageId ) @@ -701,10 +674,8 @@ * Transform an UnBindRequest message from a TwixMessage to a * SnickersMessage * - * @param twixMessage - * The message to transform - * @param messageId - * The message Id + * @param twixMessage The message to transform + * @param messageId The message Id * @return A Snickers UnBindRequestImpl */ private Message transformUnBindRequest( LdapMessage twixMessage, int messageId ) @@ -716,8 +687,7 @@ /** * Transform the Twix message to a codec neutral message. * - * @param obj - * the object to transform + * @param obj the object to transform * @return the object transformed */ public Message transform( Object obj ) @@ -890,8 +860,7 @@ /** * Transform a Ldapresult part of a Snickers Response to a Twix LdapResult * - * @param snickersLdapResult - * The Snickers LdapResult to transform + * @param snickersLdapResult The Snickers LdapResult to transform * @return A Twix LdapResult */ private LdapResult transformLdapResult( LdapResultImpl snickersLdapResult ) @@ -902,24 +871,15 @@ twixLdapResult.setResultCode( snickersLdapResult.getResultCode().getValue() ); // Snickers : String errorMessage -> Twix : LdapString errorMessage - try - { - String errorMessage = snickersLdapResult.getErrorMessage(); + String errorMessage = snickersLdapResult.getErrorMessage(); - if ( ( errorMessage == null ) || ( errorMessage.length() == 0 ) ) - { - twixLdapResult.setErrorMessage( LdapString.EMPTY_STRING ); - } - else - { - twixLdapResult.setErrorMessage( new LdapString( snickersLdapResult.getErrorMessage().getBytes() ) ); - } + if ( ( errorMessage == null ) || ( errorMessage.length() == 0 ) ) + { + twixLdapResult.setErrorMessage( "" ); } - catch ( LdapStringEncodingException lsee ) + else { - log.warn( "The error message " + snickersLdapResult.getErrorMessage() + " is invalid : " - + lsee.getMessage() ); - twixLdapResult.setErrorMessage( LdapString.EMPTY_STRING ); + twixLdapResult.setErrorMessage( new String( snickersLdapResult.getErrorMessage().getBytes() ) ); } // Snickers : String matchedDn -> Twix : LdapDN matchedDN @@ -931,6 +891,7 @@ if ( snisckersReferrals != null ) { Iterator referrals = snisckersReferrals.getLdapUrls().iterator(); + twixLdapResult.initReferrals(); while ( referrals.hasNext() ) { @@ -956,10 +917,8 @@ /** * Transform a Snickers AddResponse to a Twix AddResponse * - * @param twixMessage - * The Twix AddResponse to produce - * @param snickersMessage - * The incoming Snickers AddResponse + * @param twixMessage The Twix AddResponse to produce + * @param snickersMessage The incoming Snickers AddResponse */ private void transformAddResponse( LdapMessage twixMessage, Message snickersMessage ) { @@ -978,10 +937,8 @@ /** * Transform a Snickers BindResponse to a Twix BindResponse * - * @param twixMessage - * The Twix BindResponse to produce - * @param snickersMessage - * The incoming Snickers BindResponse + * @param twixMessage The Twix BindResponse to produce + * @param snickersMessage The incoming Snickers BindResponse */ private void transformBindResponse( LdapMessage twixMessage, Message snickersMessage ) { @@ -1009,10 +966,8 @@ /** * Transform a Snickers CompareResponse to a Twix CompareResponse * - * @param twixMessage - * The Twix CompareResponse to produce - * @param snickersMessage - * The incoming Snickers CompareResponse + * @param twixMessage The Twix CompareResponse to produce + * @param snickersMessage The incoming Snickers CompareResponse */ private void transformCompareResponse( LdapMessage twixMessage, Message snickersMessage ) { @@ -1032,10 +987,8 @@ /** * Transform a Snickers DelResponse to a Twix DelResponse * - * @param twixMessage - * The Twix DelResponse to produce - * @param snickersMessage - * The incoming Snickers DelResponse + * @param twixMessage The Twix DelResponse to produce + * @param snickersMessage The incoming Snickers DelResponse */ private void transformDelResponse( LdapMessage twixMessage, Message snickersMessage ) { @@ -1054,10 +1007,8 @@ /** * Transform a Snickers ExtendedResponse to a Twix ExtendedResponse * - * @param twixMessage - * The Twix ExtendedResponse to produce - * @param snickersMessage - * The incoming Snickers ExtendedResponse + * @param twixMessage The Twix ExtendedResponse to produce + * @param snickersMessage The incoming Snickers ExtendedResponse */ private void transformExtendedResponse( LdapMessage twixMessage, Message snickersMessage ) { @@ -1090,10 +1041,8 @@ /** * Transform a Snickers ModifyResponse to a Twix ModifyResponse * - * @param twixMessage - * The Twix ModifyResponse to produce - * @param snickersMessage - * The incoming Snickers ModifyResponse + * @param twixMessage The Twix ModifyResponse to produce + * @param snickersMessage The incoming Snickers ModifyResponse */ private void transformModifyResponse( LdapMessage twixMessage, Message snickersMessage ) { @@ -1112,10 +1061,8 @@ /** * Transform a Snickers ModifyDNResponse to a Twix ModifyDNResponse * - * @param twixMessage - * The Twix ModifyDNResponse to produce - * @param snickersMessage - * The incoming Snickers ModifyDNResponse + * @param twixMessage The Twix ModifyDNResponse to produce + * @param snickersMessage The incoming Snickers ModifyDNResponse */ private void transformModifyDNResponse( LdapMessage twixMessage, Message snickersMessage ) { @@ -1135,10 +1082,8 @@ /** * Transform a Snickers SearchResponseDone to a Twix SearchResultDone * - * @param twixMessage - * The Twix SearchResultDone to produce - * @param snickersMessage - * The incoming Snickers SearchResponseDone + * @param twixMessage The Twix SearchResultDone to produce + * @param snickersMessage The incoming Snickers SearchResponseDone */ private void transformSearchResultDone( LdapMessage twixMessage, Message snickersMessage ) { @@ -1157,10 +1102,8 @@ /** * Transform a Snickers SearchResponseEntry to a Twix SearchResultEntry * - * @param twixMessage - * The Twix SearchResultEntry to produce - * @param snickersMessage - * The incoming Snickers SearchResponseEntry + * @param twixMessage The Twix SearchResultEntry to produce + * @param snickersMessage The incoming Snickers SearchResponseEntry */ private void transformSearchResultEntry( LdapMessage twixMessage, Message snickersMessage ) { @@ -1183,10 +1126,8 @@ * Transform a Snickers SearchResponseReference to a Twix * SearchResultReference * - * @param twixMessage - * The Twix SearchResultReference to produce - * @param snickersMessage - * The incoming Snickers SearchResponseReference + * @param twixMessage The Twix SearchResultReference to produce + * @param snickersMessage The incoming Snickers SearchResponseReference */ private void transformSearchResultReference( LdapMessage twixMessage, Message snickersMessage ) { @@ -1230,8 +1171,7 @@ /** * Transform the Snickers message to a Twix message. * - * @param msg - * the message to transform + * @param msg the message to transform * @return the msg transformed */ public Object transform( Message msg ) @@ -1300,8 +1240,12 @@ return twixMessage; } - - private void transformControls( org.apache.directory.shared.ldap.codec.LdapMessage twixMessage, Message msg ) + /** + * Transforms the controls + * @param twixMessage The Twix SearchResultReference to produce + * @param msg The incoming Snickers SearchResponseReference + */ + private void transformControls( LdapMessage twixMessage, Message msg ) { Iterator list = msg.getControls().values().iterator(); while ( list.hasNext() ) @@ -1312,14 +1256,7 @@ twixControl.setCriticality( control.isCritical() ); twixControl.setControlValue( control.getEncodedValue() ); twixControl.setEncodedValue( control.getEncodedValue() ); - try - { - twixControl.setControlType( new LdapString( Asn1StringUtils.getBytesUtf8( control.getID() ) ) ); - } - catch ( LdapStringEncodingException e ) - { - log.error( "failed to encode string for control id", e ); - } + twixControl.setControlType( new String( Asn1StringUtils.getBytesUtf8( control.getID() ) ) ); twixControl.setParent( twixMessage ); } } Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/abandon/AbandonRequest.java Tue Oct 3 06:49:43 2006 @@ -32,9 +32,14 @@ /** - * A AbandonRequest Message. Its syntax is : AbandonRequest ::= [APPLICATION 16] - * MessageID MessageID ::= INTEGER (0 .. maxInt) maxInt INTEGER ::= 2147483647 -- - * (2^^31 - 1) -- + * A AbandonRequest Message. + * + * Its syntax is : + * AbandonRequest ::= [APPLICATION 16] MessageID + * + * MessageID ::= INTEGER (0 .. maxInt) + * + * maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- * * @author Apache Directory Project */ @@ -93,8 +98,7 @@ /** * Set the abandoned message ID * - * @param abandonedMessageId - * The abandoned messageID to set. + * @param abandonedMessageId The abandoned messageID to set. */ public void setAbandonedMessageId( int abandonedMessageId ) { @@ -103,9 +107,12 @@ /** - * Compute the AbandonRequest length AbandonRequest : 0x50 0x0(1..4) - * abandoned MessageId Length(AbandonRequest) = Length(0x50) + 1 + - * Length(abandoned MessageId) + * Compute the AbandonRequest length + * + * AbandonRequest : + * 0x50 0x0(1..4) abandoned MessageId + * + * Length(AbandonRequest) = Length(0x50) + 1 + Length(abandoned MessageId) */ public int computeLength() { @@ -123,8 +130,7 @@ /** * Encode the AbandonRequest message to a PDU. * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java Tue Oct 3 06:49:43 2006 @@ -20,13 +20,12 @@ package org.apache.directory.shared.ldap.codec.add; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.ber.tlv.UniversalTag; import org.apache.directory.shared.asn1.ber.tlv.Value; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapMessage; -import org.apache.directory.shared.ldap.codec.util.LdapString; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.AttributeUtils; import org.apache.directory.shared.ldap.util.StringTools; @@ -48,10 +47,16 @@ /** - * An AddRequest Message. Its syntax is : AddRequest ::= [APPLICATION 8] - * SEQUENCE { entry LDAPDN, attributes AttributeList } AttributeList ::= - * SEQUENCE OF SEQUENCE { type AttributeDescription, vals SET OF AttributeValue } - * AttributeValue ::= OCTET STRING + * An AddRequest Message. Its syntax is : + * AddRequest ::= [APPLICATION 8] SEQUENCE { + * entry LDAPDN, + * attributes AttributeList } + * + * AttributeList ::= SEQUENCE OF SEQUENCE { + * type AttributeDescription, + * vals SET OF AttributeValue } + * + * AttributeValue ::= OCTET STRING * * @author Apache Directory Project */ @@ -136,32 +141,10 @@ return attributes; } - - /** - * Create a new attributeValue - * - * @param type - * The attribute's name (called 'type' in the grammar) - */ - public void addAttributeType( LdapString type ) - { - // do not create a new attribute if we have seen this attributeType before - if ( attributes.get( type.toString().toLowerCase() ) != null ) - { - currentAttribute = attributes.get( type.toString().toLowerCase() ); - return; - } - - // fix this to use LockableAttributeImpl(type.getString().toLowerCase()) - currentAttribute = new BasicAttribute( type.getString().toLowerCase() ); - attributes.put( currentAttribute ); - } - /** * Create a new attributeValue * - * @param type - * The attribute's name (called 'type' in the grammar) + * @param type The attribute's name (called 'type' in the grammar) */ public void addAttributeType( String type ) { @@ -181,8 +164,7 @@ /** * Add a new value to the current attribute * - * @param value - * The value to be added + * @param value The value to be added */ public void addAttributeValue( Object value ) { @@ -204,8 +186,7 @@ /** * Set the added DN. * - * @param entry - * The entry to set. + * @param entry The entry to set. */ public void setEntry( LdapDN entry ) { @@ -214,19 +195,48 @@ /** - * Compute the AddRequest length AddRequest : 0x68 L1 | +--> 0x04 L2 entry - * +--> 0x30 L3 (attributes) | +--> 0x30 L4-1 (attribute) | | | +--> 0x04 - * L5-1 type | +--> 0x31 L6-1 (values) | | | +--> 0x04 L7-1-1 value | +--> - * ... | +--> 0x04 L7-1-n value | +--> 0x30 L4-2 (attribute) | | | +--> 0x04 - * L5-2 type | +--> 0x31 L6-2 (values) | | | +--> 0x04 L7-2-1 value | +--> - * ... | +--> 0x04 L7-2-n value | +--> ... | +--> 0x30 L4-m (attribute) | - * +--> 0x04 L5-m type +--> 0x31 L6-m (values) | +--> 0x04 L7-m-1 value +--> - * ... +--> 0x04 L7-m-n value + * Compute the AddRequest length + * + * AddRequest : + * + * 0x68 L1 + * | + * +--> 0x04 L2 entry + * +--> 0x30 L3 (attributes) + * | + * +--> 0x30 L4-1 (attribute) + * | | + * | +--> 0x04 L5-1 type + * | +--> 0x31 L6-1 (values) + * | | + * | +--> 0x04 L7-1-1 value + * | +--> ... + * | +--> 0x04 L7-1-n value + * | + * +--> 0x30 L4-2 (attribute) + * | | + * | +--> 0x04 L5-2 type + * | +--> 0x31 L6-2 (values) + * | | + * | +--> 0x04 L7-2-1 value + * | +--> ... + * | +--> 0x04 L7-2-n value + * | + * +--> ... + * | + * +--> 0x30 L4-m (attribute) + * | + * +--> 0x04 L5-m type + * +--> 0x31 L6-m (values) + * | + * +--> 0x04 L7-m-1 value + * +--> ... + * +--> 0x04 L7-m-n value */ public int computeLength() { // The entry - addRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ); + addRequestLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ); // The attributes sequence attributesLength = 0; @@ -246,7 +256,7 @@ // Get the type length int idLength = attribute.getID().getBytes().length; - localAttributeLength = 1 + Length.getNbBytes( idLength ) + idLength; + localAttributeLength = 1 + TLV.getNbBytes( idLength ) + idLength; // The values try @@ -264,16 +274,16 @@ if ( value instanceof String ) { int valueLength = StringTools.getBytesUtf8( ( String ) value ).length; - localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength; + localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength; } else { int valueLength = ( ( byte[] ) value ).length; - localValuesLength += 1 + Length.getNbBytes( valueLength ) + valueLength; + localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength; } } - localAttributeLength += 1 + Length.getNbBytes( localValuesLength ) + localValuesLength; + localAttributeLength += 1 + TLV.getNbBytes( localValuesLength ) + localValuesLength; } } @@ -283,17 +293,17 @@ } // add the attribute length to the attributes length - attributesLength += 1 + Length.getNbBytes( localAttributeLength ) + localAttributeLength; + attributesLength += 1 + TLV.getNbBytes( localAttributeLength ) + localAttributeLength; attributeLength.add( new Integer( localAttributeLength ) ); valuesLength.add( new Integer( localValuesLength ) ); } } - addRequestLength += 1 + Length.getNbBytes( attributesLength ) + attributesLength; + addRequestLength += 1 + TLV.getNbBytes( attributesLength ) + attributesLength; // Return the result. - int result = 1 + Length.getNbBytes( addRequestLength ) + addRequestLength; + int result = 1 + TLV.getNbBytes( addRequestLength ) + addRequestLength; if ( IS_DEBUG ) { @@ -305,15 +315,28 @@ /** - * Encode the AddRequest message to a PDU. AddRequest : 0x68 LL 0x04 LL - * entry 0x30 LL attributesList 0x30 LL attributeList 0x04 LL - * attributeDescription 0x31 LL attributeValues 0x04 LL attributeValue ... - * 0x04 LL attributeValue ... 0x30 LL attributeList 0x04 LL - * attributeDescription 0x31 LL attributeValue 0x04 LL attributeValue ... - * 0x04 LL attributeValue + * Encode the AddRequest message to a PDU. + * + * AddRequest : + * + * 0x68 LL + * 0x04 LL entry + * 0x30 LL attributesList + * 0x30 LL attributeList + * 0x04 LL attributeDescription + * 0x31 LL attributeValues + * 0x04 LL attributeValue + * ... + * 0x04 LL attributeValue + * ... + * 0x30 LL attributeList + * 0x04 LL attributeDescription + * 0x31 LL attributeValue + * 0x04 LL attributeValue + * ... + * 0x04 LL attributeValue * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -327,14 +350,14 @@ { // The AddRequest Tag buffer.put( LdapConstants.ADD_REQUEST_TAG ); - buffer.put( Length.getBytes( addRequestLength ) ); + buffer.put( TLV.getBytes( addRequestLength ) ); // The entry Value.encode( buffer, LdapDN.getBytes( entry ) ); // The attributes sequence buffer.put( UniversalTag.SEQUENCE_TAG ); - buffer.put( Length.getBytes( attributesLength ) ); + buffer.put( TLV.getBytes( attributesLength ) ); // The partial attribute list if ( ( attributes != null ) && ( attributes.size() != 0 ) ) @@ -350,7 +373,7 @@ // The attributes list sequence buffer.put( UniversalTag.SEQUENCE_TAG ); int localAttributeLength = ( ( Integer ) attributeLength.get( attributeNumber ) ).intValue(); - buffer.put( Length.getBytes( localAttributeLength ) ); + buffer.put( TLV.getBytes( localAttributeLength ) ); // The attribute type Value.encode( buffer, attribute.getID() ); @@ -358,7 +381,7 @@ // The values buffer.put( UniversalTag.SET_TAG ); int localValuesLength = ( ( Integer ) valuesLength.get( attributeNumber ) ).intValue(); - buffer.put( Length.getBytes( localValuesLength ) ); + buffer.put( TLV.getBytes( localValuesLength ) ); try { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddResponse.java Tue Oct 3 06:49:43 2006 @@ -23,15 +23,16 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapResponse; /** - * An AddResponse Message. Its syntax is : AddResponse ::= [APPLICATION 9] - * LDAPResult + * An AddResponse Message. Its syntax is : + * + * AddResponse ::= [APPLICATION 9] LDAPResult * * @author Apache Directory Project */ @@ -64,22 +65,30 @@ /** - * Compute the AddResponse length AddResponse : 0x69 L1 | +--> LdapResult L1 = - * Length(LdapResult) Length(AddResponse) = Length(0x69) + Length(L1) + L1 + * Compute the AddResponse length + * + * AddResponse : + * + * 0x69 L1 + * | + * +--> LdapResult + * + * L1 = Length(LdapResult) + * + * Length(AddResponse) = Length(0x69) + Length(L1) + L1 */ public int computeLength() { int ldapResponseLength = super.computeLength(); - return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength; + return 1 + TLV.getNbBytes( ldapResponseLength ) + ldapResponseLength; } /** * Encode the AddResponse message to a PDU. * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -93,7 +102,7 @@ { // The tag buffer.put( LdapConstants.ADD_RESPONSE_TAG ); - buffer.put( Length.getBytes( getLdapResponseLength() ) ); + buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindRequest.java Tue Oct 3 06:49:43 2006 @@ -23,7 +23,7 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.ber.tlv.Value; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; @@ -55,10 +55,6 @@ /** The bind request length */ private transient int bindRequestLength; - - // ~ Constructors - // ------------------------------------------------------------------------------- - /** * Creates a new BindRequest object. */ @@ -67,10 +63,6 @@ super(); } - - // ~ Methods - // ------------------------------------------------------------------------------------ - /** * Get the message type * @@ -118,8 +110,7 @@ /** * Set the user authentication * - * @param authentication - * The user authentication + * @param authentication The user authentication */ public void setAuthentication( LdapAuthentication authentication ) { @@ -141,8 +132,7 @@ /** * Set the user name * - * @param name - * The user name + * @param name The user name */ public void setName( LdapDN name ) { @@ -175,8 +165,7 @@ /** * Set the protocol version * - * @param version - * The protocol version + * @param version The protocol version */ public void setVersion( int version ) { @@ -185,34 +174,48 @@ /** - * Compute the BindRequest length BindRequest : 0x60 L1 | +--> 0x02 0x01 - * (1..127) version +--> 0x04 L2 name +--> authentication L2 = Length(name) - * L3/4 = Length(authentication) Length(BindRequest) = Length(0x60) + - * Length(L1) + L1 + Length(0x02) + 1 + 1 + Length(0x04) + Length(L2) + L2 + - * Length(authentication) + * Compute the BindRequest length + * + * BindRequest : + * 0x60 L1 + * | + * +--> 0x02 0x01 (1..127) version + * +--> 0x04 L2 name + * +--> authentication + * + * L2 = Length(name) + * L3/4 = Length(authentication) + * Length(BindRequest) = Length(0x60) + Length(L1) + L1 + Length(0x02) + 1 + 1 + + * Length(0x04) + Length(L2) + L2 + Length(authentication) */ public int computeLength() { bindRequestLength = 1 + 1 + 1; // Initialized with version // The name - bindRequestLength += 1 + Length.getNbBytes( LdapDN.getNbBytes( name ) ) + LdapDN.getNbBytes( name ); + bindRequestLength += 1 + TLV.getNbBytes( LdapDN.getNbBytes( name ) ) + LdapDN.getNbBytes( name ); // The authentication bindRequestLength += authentication.computeLength(); // Return the result. - return 1 + Length.getNbBytes( bindRequestLength ) + bindRequestLength; + return 1 + TLV.getNbBytes( bindRequestLength ) + bindRequestLength; } /** - * Encode the BindRequest message to a PDU. BindRequest : 0x60 LL 0x02 LL - * version 0x04 LL name authentication.encode() 0x80 LL simple / \ 0x83 LL - * mechanism [0x04 LL credential] + * Encode the BindRequest message to a PDU. + * + * BindRequest : * - * @param buffer - * The buffer where to put the PDU + * 0x60 LL + * 0x02 LL version 0x80 LL simple + * 0x04 LL name / + * authentication.encode() + * \ 0x83 LL mechanism [0x04 LL credential] + * + * + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -226,7 +229,7 @@ { // The BindRequest Tag buffer.put( LdapConstants.BIND_REQUEST_TAG ); - buffer.put( Length.getBytes( bindRequestLength ) ); + buffer.put( TLV.getBytes( bindRequestLength ) ); } catch ( BufferOverflowException boe ) @@ -280,4 +283,62 @@ return sb.toString(); } + + /* Used only for test perfs + public static void main( String[] args ) throws Exception + { + Asn1Decoder ldapDecoder = new LdapDecoder(); + + ByteBuffer stream = ByteBuffer.allocate( 0x52 ); + stream.put( new byte[] + { + 0x30, 0x50, // LDAPMessage ::=SEQUENCE { + 0x02, 0x01, 0x01, // messageID MessageID + 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ... + // BindRequest ::= APPLICATION[0] SEQUENCE { + 0x02, 0x01, 0x03, // version INTEGER (1..127), + 0x04, 0x1F, // name LDAPDN, + 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', 'e', 'x', 'a', + 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', + ( byte ) 0x80, 0x08, // authentication AuthenticationChoice + // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING, + // ... + 'p', 'a', 's', 's', 'w', 'o', 'r', 'd', + ( byte ) 0xA0, 0x1B, // A control + 0x30, 0x19, + 0x04, 0x17, + 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E, 0x31, 0x2E, 0x31, 0x31, 0x33, 0x37, 0x33, + 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 + } ); + + stream.flip(); + + // Allocate a LdapMessage Container + IAsn1Container ldapMessageContainer = new LdapMessageContainer(); + + // Decode the BindRequest PDU + try + { + long t0 = System.currentTimeMillis(); + for ( int i = 0; i < 10000000; i++ ) + { + ldapDecoder.decode( stream, ldapMessageContainer ); + ( ( LdapMessageContainer ) ldapMessageContainer).clean(); + stream.flip(); + } + long t1 = System.currentTimeMillis(); + System.out.println( "Delta = " + ( t1 - t0 ) ); + + ldapDecoder.decode( stream, ldapMessageContainer ); + } + catch ( DecoderException de ) + { + de.printStackTrace(); + } + catch ( NamingException ne ) + { + ne.printStackTrace(); + } + } + */ } Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/BindResponse.java Tue Oct 3 06:49:43 2006 @@ -23,16 +23,21 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapResponse; /** - * A BindResponse Message. Its syntax is : BindResponse ::= [APPLICATION 1] - * SEQUENCE { COMPONENTS OF LDAPResult, serverSaslCreds [7] OCTET STRING - * OPTIONAL } LdapResult ::= resultCode matchedDN errorMessage (referrals)* + * A BindResponse Message. + * + * Its syntax is : + * BindResponse ::= [APPLICATION 1] SEQUENCE { + * COMPONENTS OF LDAPResult, + * serverSaslCreds [7] OCTET STRING OPTIONAL } + * + * LdapResult ::= resultCode matchedDN errorMessage (referrals)* * * @author Apache Directory Project */ @@ -86,8 +91,7 @@ /** * Set the server sasl credentials * - * @param serverSaslCreds - * The serverSaslCreds to set. + * @param serverSaslCreds The serverSaslCreds to set. */ public void setServerSaslCreds( byte[] serverSaslCreds ) { @@ -96,10 +100,16 @@ /** - * Compute the BindResponse length BindResponse : 0x61 L1 | +--> LdapResult - * +--> [serverSaslCreds] L1 = Length(LdapResult) [ + - * Length(serverSaslCreds) ] Length(BindResponse) = Length(0x61) + - * Length(L1) + L1 + * Compute the BindResponse length + * + * BindResponse : + * 0x61 L1 + * | + * +--> LdapResult + * +--> [serverSaslCreds] + * + * L1 = Length(LdapResult) [ + Length(serverSaslCreds) ] + * Length(BindResponse) = Length(0x61) + Length(L1) + L1 */ public int computeLength() { @@ -109,11 +119,11 @@ if ( serverSaslCreds != null ) { - bindResponseLength += 1 + Length.getNbBytes( ( ( byte[] ) serverSaslCreds ).length ) + bindResponseLength += 1 + TLV.getNbBytes( ( ( byte[] ) serverSaslCreds ).length ) + ( ( byte[] ) serverSaslCreds ).length; } - return 1 + Length.getNbBytes( bindResponseLength ) + bindResponseLength; + return 1 + TLV.getNbBytes( bindResponseLength ) + bindResponseLength; } @@ -121,8 +131,7 @@ * Encode the BindResponse message to a PDU. BindResponse : * LdapResult.encode [0x87 LL serverSaslCreds] * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -136,7 +145,7 @@ { // The BindResponse Tag buffer.put( LdapConstants.BIND_RESPONSE_TAG ); - buffer.put( Length.getBytes( bindResponseLength ) ); + buffer.put( TLV.getBytes( bindResponseLength ) ); // The LdapResult super.encode( buffer ); @@ -146,7 +155,7 @@ { buffer.put( ( byte ) LdapConstants.SERVER_SASL_CREDENTIAL_TAG ); - buffer.put( Length.getBytes( ( ( byte[] ) serverSaslCreds ).length ) ); + buffer.put( TLV.getBytes( ( ( byte[] ) serverSaslCreds ).length ) ); if ( ( ( byte[] ) serverSaslCreds ).length != 0 ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SaslCredentials.java Tue Oct 3 06:49:43 2006 @@ -23,11 +23,11 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.ber.tlv.Value; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; -import org.apache.directory.shared.ldap.codec.util.LdapString; +import org.apache.directory.shared.ldap.util.StringTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +51,10 @@ /** * Any mechanism defined in RFC 2222 : KERBEROS_V4, GSSAPI, SKEY, EXTERNAL */ - private LdapString mechanism; + private String mechanism; + + /** The mechanism bytes */ + private transient byte[] mechanismBytes; /** optional credentials of the user */ private byte[] credentials; @@ -80,8 +83,7 @@ /** * Set the credentials * - * @param credentials - * The credentials + * @param credentials The credentials */ public void setCredentials( byte[] credentials ) { @@ -97,40 +99,50 @@ public String getMechanism() { - return ( ( mechanism == null ) ? null : mechanism.getString() ); + return ( ( mechanism == null ) ? null : mechanism ); } /** * Set the mechanism * - * @param mechanism - * The mechanism + * @param mechanism The mechanism */ - public void setMechanism( LdapString mechanism ) + public void setMechanism( String mechanism ) { this.mechanism = mechanism; } /** - * Compute the Sasl authentication length Sasl authentication : 0xA3 L1 0x04 - * L2 mechanism [0x04 L3 credentials] L2 = Length(mechanism) L3 = - * Length(credentials) L1 = L2 + L3 Length(Sasl authentication) = - * Length(0xA3) + Length(L1) + Length(0x04) + Length(L2) + Length(mechanism) [+ - * Length(0x04) + Length(L3) + Length(credentials)] + * Compute the Sasl authentication length + * + * Sasl authentication : + * + * 0xA3 L1 + * 0x04 L2 mechanism + * [0x04 L3 credentials] + * + * L2 = Length(mechanism) + * L3 = Length(credentials) + * L1 = L2 + L3 + * + * Length(Sasl authentication) = Length(0xA3) + Length(L1) + + * Length(0x04) + Length(L2) + Length(mechanism) + * [+ Length(0x04) + Length(L3) + Length(credentials)] */ public int computeLength() { - mechanismLength = 1 + Length.getNbBytes( mechanism.getNbBytes() ) + mechanism.getNbBytes(); + mechanismBytes = StringTools.getBytesUtf8( mechanism ); + mechanismLength = 1 + TLV.getNbBytes( mechanismBytes.length ) + mechanismBytes.length; credentialsLength = 0; if ( credentials != null ) { - credentialsLength = 1 + Length.getNbBytes( credentials.length ) + credentials.length; + credentialsLength = 1 + TLV.getNbBytes( credentials.length ) + credentials.length; } - int saslLength = 1 + Length.getNbBytes( mechanismLength + credentialsLength ) + mechanismLength + int saslLength = 1 + TLV.getNbBytes( mechanismLength + credentialsLength ) + mechanismLength + credentialsLength; if ( IS_DEBUG ) @@ -143,11 +155,14 @@ /** - * Encode the sasl authentication to a PDU. SimpleAuthentication : 0xA3 L1 - * 0x04 L2 mechanism [0x04 L3 credentials] + * Encode the sasl authentication to a PDU. + * + * SimpleAuthentication : + * 0xA3 L1 + * 0x04 L2 mechanism + * [0x04 L3 credentials] * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -163,9 +178,9 @@ // The saslAuthentication Tag buffer.put( ( byte ) LdapConstants.BIND_REQUEST_SASL_TAG ); - buffer.put( Length.getBytes( mechanismLength + credentialsLength ) ); + buffer.put( TLV.getBytes( mechanismLength + credentialsLength ) ); - Value.encode( buffer, mechanism.toString() ); + Value.encode( buffer, mechanism ); if ( credentials != null ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/bind/SimpleAuthentication.java Tue Oct 3 06:49:43 2006 @@ -23,7 +23,7 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.slf4j.Logger; @@ -67,8 +67,7 @@ /** * Set the simple password * - * @param simple - * The simple password + * @param simple The simple password */ public void setSimple( byte[] simple ) { @@ -77,15 +76,18 @@ /** - * Compute the Simple authentication length Simple authentication : 0x80 L1 - * simple L1 = Length(simple) Length(Simple authentication) = Length(0x80) + - * Length(L1) + Length(simple) + * Compute the Simple authentication length + * + * Simple authentication : 0x80 L1 simple + * + * L1 = Length(simple) + * Length(Simple authentication) = Length(0x80) + Length(L1) + Length(simple) */ public int computeLength() { int length = 1; - length += Length.getNbBytes( simple.length ) + simple.length; + length += TLV.getNbBytes( simple.length ) + simple.length; if ( IS_DEBUG ) { @@ -97,11 +99,11 @@ /** - * Encode the simple authentication to a PDU. SimpleAuthentication : 0x80 LL - * simple + * Encode the simple authentication to a PDU. + * + * SimpleAuthentication : 0x80 LL simple * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -116,7 +118,7 @@ { // The simpleAuthentication Tag buffer.put( ( byte ) LdapConstants.BIND_REQUEST_SIMPLE_TAG ); - buffer.put( Length.getBytes( simple.length ) ); + buffer.put( TLV.getBytes( simple.length ) ); if ( simple.length != 0 ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareRequest.java Tue Oct 3 06:49:43 2006 @@ -23,22 +23,28 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.ber.tlv.UniversalTag; import org.apache.directory.shared.asn1.ber.tlv.Value; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapMessage; -import org.apache.directory.shared.ldap.codec.util.LdapString; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.util.StringTools; /** - * A CompareRequest Message. Its syntax is : CompareRequest ::= [APPLICATION 14] - * SEQUENCE { entry LDAPDN, ava AttributeValueAssertion } - * AttributeValueAssertion ::= SEQUENCE { attributeDesc AttributeDescription, - * assertionValue AssertionValue } AttributeDescription ::= LDAPString + * A CompareRequest Message. Its syntax is : + * CompareRequest ::= [APPLICATION 14] SEQUENCE { + * entry LDAPDN, + * ava AttributeValueAssertion } + * + * AttributeValueAssertion ::= SEQUENCE { + * attributeDesc AttributeDescription, + * assertionValue AssertionValue } + * + * AttributeDescription ::= LDAPString + * * AssertionValue ::= OCTET STRING * * @author Apache Directory Project @@ -52,7 +58,7 @@ private LdapDN entry; /** The attribute to be compared */ - private LdapString attributeDesc; + private String attributeDesc; /** The value to be compared */ private Object assertionValue; @@ -104,8 +110,7 @@ /** * Set the entry to be compared * - * @param entry - * The entry to set. + * @param entry The entry to set. */ public void setEntry( LdapDN entry ) { @@ -127,8 +132,7 @@ /** * Set the assertion value * - * @param assertionValue - * The assertionValue to set. + * @param assertionValue The assertionValue to set. */ public void setAssertionValue( Object assertionValue ) { @@ -143,64 +147,78 @@ */ public String getAttributeDesc() { - return ( ( attributeDesc == null ) ? "" : attributeDesc.getString() ); + return ( ( attributeDesc == null ) ? "" : attributeDesc ); } /** * Set the attribute description * - * @param attributeDesc - * The attributeDesc to set. + * @param attributeDesc The attributeDesc to set. */ - public void setAttributeDesc( LdapString attributeDesc ) + public void setAttributeDesc( String attributeDesc ) { this.attributeDesc = attributeDesc; } /** - * Compute the CompareRequest length CompareRequest : 0x6E L1 | +--> 0x04 L2 - * entry +--> 0x30 L3 (ava) | +--> 0x04 L4 attributeDesc +--> 0x04 L5 - * assertionValue L3 = Length(0x04) + Length(L4) + L4 + Length(0x04) + - * Length(L5) + L5 Length(CompareRequest) = Length(0x6E) + Length(L1) + L1 + - * Length(0x04) + Length(L2) + L2 + Length(0x30) + Length(L3) + L3 + * Compute the CompareRequest length * - * @return DOCUMENT ME! + * CompareRequest : + * 0x6E L1 + * | + * +--> 0x04 L2 entry + * +--> 0x30 L3 (ava) + * | + * +--> 0x04 L4 attributeDesc + * +--> 0x04 L5 assertionValue + * + * L3 = Length(0x04) + Length(L4) + L4 + Length(0x04) + + * Length(L5) + L5 + * Length(CompareRequest) = Length(0x6E) + Length(L1) + L1 + + * Length(0x04) + Length(L2) + L2 + Length(0x30) + Length(L3) + L3 + * + * @return The CompareRequest PDU's length */ public int computeLength() { // The entry - compareRequestLength = 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ); + compareRequestLength = 1 + TLV.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ); // The attribute value assertion - avaLength = 1 + Length.getNbBytes( attributeDesc.getNbBytes() ) + attributeDesc.getNbBytes(); + int attributeDescLength = StringTools.getBytesUtf8( attributeDesc ).length; + avaLength = 1 + TLV.getNbBytes( attributeDescLength ) + attributeDescLength; if ( assertionValue instanceof String ) { int assertionValueLength = StringTools.getBytesUtf8( ( String ) assertionValue ).length; - avaLength += 1 + Length.getNbBytes( assertionValueLength ) + assertionValueLength; + avaLength += 1 + TLV.getNbBytes( assertionValueLength ) + assertionValueLength; } else { - avaLength += 1 + Length.getNbBytes( ( ( byte[] ) assertionValue ).length ) + avaLength += 1 + TLV.getNbBytes( ( ( byte[] ) assertionValue ).length ) + ( ( byte[] ) assertionValue ).length; } - compareRequestLength += 1 + Length.getNbBytes( avaLength ) + avaLength; + compareRequestLength += 1 + TLV.getNbBytes( avaLength ) + avaLength; - return 1 + Length.getNbBytes( compareRequestLength ) + compareRequestLength; + return 1 + TLV.getNbBytes( compareRequestLength ) + compareRequestLength; } /** - * Encode the CompareRequest message to a PDU. CompareRequest : 0x6E LL 0x04 - * LL entry 0x30 LL attributeValueAssertion 0x04 LL attributeDesc 0x04 LL - * assertionValue + * Encode the CompareRequest message to a PDU. + * + * CompareRequest : + * 0x6E LL + * 0x04 LL entry + * 0x30 LL attributeValueAssertion + * 0x04 LL attributeDesc + * 0x04 LL assertionValue * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -214,14 +232,14 @@ { // The CompareRequest Tag buffer.put( LdapConstants.COMPARE_REQUEST_TAG ); - buffer.put( Length.getBytes( compareRequestLength ) ); + buffer.put( TLV.getBytes( compareRequestLength ) ); // The entry Value.encode( buffer, LdapDN.getBytes( entry ) ); // The attributeValueAssertion sequence Tag buffer.put( UniversalTag.SEQUENCE_TAG ); - buffer.put( Length.getBytes( avaLength ) ); + buffer.put( TLV.getBytes( avaLength ) ); } catch ( BufferOverflowException boe ) { @@ -229,7 +247,7 @@ } // The attributeDesc - Value.encode( buffer, attributeDesc.getString() ); + Value.encode( buffer, attributeDesc ); // The assertionValue if ( assertionValue instanceof String ) Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareResponse.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareResponse.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareResponse.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/compare/CompareResponse.java Tue Oct 3 06:49:43 2006 @@ -23,15 +23,16 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapResponse; /** - * An CompareResponse Message. Its syntax is : CompareResponse ::= [APPLICATION - * 15] LDAPResult + * An CompareResponse Message. Its syntax is : + * + * CompareResponse ::= [APPLICATION 15] LDAPResult * * @author Apache Directory Project */ @@ -64,23 +65,30 @@ /** - * Compute the CompareResponse length CompareResponse : 0x6F L1 | +--> - * LdapResult L1 = Length(LdapResult) Length(CompareResponse) = Length(0x6F) + - * Length(L1) + L1 + * Compute the CompareResponse length + * + * CompareResponse : + * + * 0x6F L1 + * | + * +--> LdapResult + * + * L1 = Length(LdapResult) + * + * Length(CompareResponse) = Length(0x6F) + Length(L1) + L1 */ public int computeLength() { int ldapResponseLength = super.computeLength(); - return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength; + return 1 + TLV.getNbBytes( ldapResponseLength ) + ldapResponseLength; } /** * Encode the CompareResponse message to a PDU. * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -94,7 +102,7 @@ { // The tag buffer.put( LdapConstants.COMPARE_RESPONSE_TAG ); - buffer.put( Length.getBytes( getLdapResponseLength() ) ); + buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelRequest.java Tue Oct 3 06:49:43 2006 @@ -23,7 +23,7 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapMessage; @@ -31,7 +31,11 @@ /** - * A DelRequest Message. Its syntax is : DelRequest ::= [APPLICATION 10] LDAPDN + * A DelRequest Message. + * + * Its syntax is : + * + * DelRequest ::= [APPLICATION 10] LDAPDN * * @author Apache Directory Project */ @@ -84,8 +88,7 @@ /** * Set the entry to be deleted * - * @param entry - * The entry to set. + * @param entry The entry to set. */ public void setEntry( LdapDN entry ) { @@ -94,21 +97,28 @@ /** - * Compute the DelRequest length DelRequest : 0x4A L1 entry L1 = - * Length(entry) Length(DelRequest) = Length(0x4A) + Length(L1) + L1 + * Compute the DelRequest length + * + * DelRequest : + * 0x4A L1 entry + * + * L1 = Length(entry) + * Length(DelRequest) = Length(0x4A) + Length(L1) + L1 */ public int computeLength() { // The entry - return 1 + Length.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ); + return 1 + TLV.getNbBytes( LdapDN.getNbBytes( entry ) ) + LdapDN.getNbBytes( entry ); } /** - * Encode the DelRequest message to a PDU. DelRequest : 0x4A LL entry + * Encode the DelRequest message to a PDU. + * + * DelRequest : + * 0x4A LL entry * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -124,7 +134,7 @@ buffer.put( LdapConstants.DEL_REQUEST_TAG ); // The entry - buffer.put( Length.getBytes( LdapDN.getNbBytes( entry ) ) ); + buffer.put( TLV.getBytes( LdapDN.getNbBytes( entry ) ) ); buffer.put( LdapDN.getBytes( entry ) ); } catch ( BufferOverflowException boe ) Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelResponse.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelResponse.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelResponse.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelResponse.java Tue Oct 3 06:49:43 2006 @@ -23,15 +23,16 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.ldap.codec.LdapConstants; import org.apache.directory.shared.ldap.codec.LdapResponse; /** - * An DelResponse Message. Its syntax is : DelResponse ::= [APPLICATION 11] - * LDAPResult + * An DelResponse Message. Its syntax is : + * + * DelResponse ::= [APPLICATION 11] LDAPResult * * @author Apache Directory Project */ @@ -61,22 +62,30 @@ /** - * Compute the DelResponse length DelResponse : 0x6B L1 | +--> LdapResult L1 = - * Length(LdapResult) Length(DelResponse) = Length(0x6B) + Length(L1) + L1 + * Compute the DelResponse length + * + * DelResponse : + * + * 0x6B L1 + * | + * +--> LdapResult + * + * L1 = Length(LdapResult) + * + * Length(DelResponse) = Length(0x6B) + Length(L1) + L1 */ public int computeLength() { int ldapResponseLength = super.computeLength(); - return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength; + return 1 + TLV.getNbBytes( ldapResponseLength ) + ldapResponseLength; } /** * Encode the DelResponse message to a PDU. * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -90,7 +99,7 @@ { // The tag buffer.put( LdapConstants.DEL_RESPONSE_TAG ); - buffer.put( Length.getBytes( getLdapResponseLength() ) ); + buffer.put( TLV.getBytes( getLdapResponseLength() ) ); } catch ( BufferOverflowException boe ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedRequest.java Tue Oct 3 06:49:43 2006 @@ -23,7 +23,7 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.asn1.primitives.OID; import org.apache.directory.shared.ldap.codec.LdapConstants; @@ -32,9 +32,10 @@ /** - * A ExtendedRequest Message. Its syntax is : ExtendedRequest ::= [APPLICATION - * 23] SEQUENCE { requestName [0] LDAPOID, requestValue [1] OCTET STRING - * OPTIONAL } + * A ExtendedRequest Message. Its syntax is : + * ExtendedRequest ::= [APPLICATION 23] SEQUENCE { + * requestName [0] LDAPOID, + * requestValue [1] OCTET STRING OPTIONAL } * * @author Apache Directory Project */ @@ -96,8 +97,7 @@ /** * Set the extended request name * - * @param requestName - * The request name to set. + * @param requestName The request name to set. */ public void setRequestName( OID requestName ) { @@ -119,8 +119,7 @@ /** * Set the extended request value * - * @param requestValue - * The request value to set. + * @param requestValue The request value to set. */ public void setRequestValue( byte[] requestValue ) { @@ -129,32 +128,44 @@ /** - * Compute the ExtendedRequest length ExtendedRequest : 0x77 L1 | +--> 0x80 - * L2 name [+--> 0x81 L3 value] L1 = Length(0x80) + Length(L2) + L2 [+ - * Length(0x81) + Length(L3) + L3] Length(ExtendedRequest) = Length(0x77) + - * Length(L1) + L1 + * Compute the ExtendedRequest length + * + * ExtendedRequest : + * + * 0x77 L1 + * | + * +--> 0x80 L2 name + * [+--> 0x81 L3 value] + * + * L1 = Length(0x80) + Length(L2) + L2 + * [+ Length(0x81) + Length(L3) + L3] + * + * Length(ExtendedRequest) = Length(0x77) + Length(L1) + L1 */ public int computeLength() { oidLength = requestName.toString().length(); - extendedRequestLength = 1 + Length.getNbBytes( oidLength ) + oidLength; + extendedRequestLength = 1 + TLV.getNbBytes( oidLength ) + oidLength; if ( requestValue != null ) { - extendedRequestLength += 1 + Length.getNbBytes( ( ( byte[] ) requestValue ).length ) + extendedRequestLength += 1 + TLV.getNbBytes( ( ( byte[] ) requestValue ).length ) + ( ( byte[] ) requestValue ).length; } - return 1 + Length.getNbBytes( extendedRequestLength ) + extendedRequestLength; + return 1 + TLV.getNbBytes( extendedRequestLength ) + extendedRequestLength; } /** - * Encode the ExtendedRequest message to a PDU. ExtendedRequest : 0x80 LL - * resquest name [0x81 LL request value] + * Encode the ExtendedRequest message to a PDU. + * + * ExtendedRequest : + * + * 0x80 LL resquest name + * [0x81 LL request value] * - * @param buffer - * The buffer where to put the PDU + * @param buffer The buffer where to put the PDU * @return The PDU. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException @@ -168,7 +179,7 @@ { // The BindResponse Tag buffer.put( LdapConstants.EXTENDED_REQUEST_TAG ); - buffer.put( Length.getBytes( extendedRequestLength ) ); + buffer.put( TLV.getBytes( extendedRequestLength ) ); // The requestName, if any if ( requestName == null ) @@ -177,7 +188,7 @@ } buffer.put( ( byte ) LdapConstants.EXTENDED_REQUEST_NAME_TAG ); - buffer.put( Length.getBytes( oidLength ) ); + buffer.put( TLV.getBytes( oidLength ) ); if ( requestName.getOIDLength() != 0 ) { @@ -189,7 +200,7 @@ { buffer.put( ( byte ) LdapConstants.EXTENDED_REQUEST_VALUE_TAG ); - buffer.put( Length.getBytes( requestValue.length ) ); + buffer.put( TLV.getBytes( requestValue.length ) ); if ( requestValue.length != 0 ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponse.java Tue Oct 3 06:49:43 2006 @@ -23,7 +23,7 @@ import java.nio.BufferOverflowException; import java.nio.ByteBuffer; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.codec.EncoderException; import org.apache.directory.shared.asn1.primitives.OID; import org.apache.directory.shared.ldap.codec.LdapConstants; @@ -32,9 +32,11 @@ /** - * A ExtendedResponse Message. Its syntax is : ExtendedResponse ::= [APPLICATION - * 24] SEQUENCE { COMPONENTS OF LDAPResult, responseName [10] LDAPOID OPTIONAL, - * response [11] OCTET STRING OPTIONAL } + * A ExtendedResponse Message. Its syntax is : + * ExtendedResponse ::= [APPLICATION 24] SEQUENCE { + * COMPONENTS OF LDAPResult, + * responseName [10] LDAPOID OPTIONAL, + * response [11] OCTET STRING OPTIONAL } * * @author Apache Directory Project */ @@ -96,8 +98,7 @@ /** * Set the extended response name * - * @param responseName - * The name to set. + * @param responseName The name to set. */ public void setResponseName( OID responseName ) { @@ -119,8 +120,7 @@ /** * Set the extended response * - * @param response - * The response to set. + * @param response The response to set. */ public void setResponse( Object response ) { @@ -129,17 +129,19 @@ /** - * Compute the ExtendedResponse length - * ExtendedResponse : - * 0x78 L1 - * | - * +--> LdapResult - * [+--> 0x8A L2 name - * [+--> 0x8B L3 response]] - * - * L1 = Length(LdapResult) - * [ + Length(0x8A) + Length(L2) + L2 - * [ + Length(0x8B) + Length(L3) + L3]] + * Compute the ExtendedResponse length + * + * ExtendedResponse : + * + * 0x78 L1 + * | + * +--> LdapResult + * [+--> 0x8A L2 name + * [+--> 0x8B L3 response]] + * + * L1 = Length(LdapResult) + * [ + Length(0x8A) + Length(L2) + L2 + * [ + Length(0x8B) + Length(L3) + L3]] * * Length(ExtendedResponse) = Length(0x78) + Length(L1) + L1 * @@ -152,30 +154,33 @@ if ( responseName != null ) { responseNameLength = responseName.toString().length(); - extendedResponseLength += 1 + Length.getNbBytes( responseNameLength ) + responseNameLength; - } + extendedResponseLength += 1 + TLV.getNbBytes( responseNameLength ) + responseNameLength; - if ( response != null ) - { - if ( response instanceof String ) - { - int responseLength = StringTools.getBytesUtf8( ( String ) response ).length; - extendedResponseLength += 1 + Length.getNbBytes( responseLength ) + responseLength; - } - else + if ( response != null ) { - extendedResponseLength += 1 + Length.getNbBytes( ( ( byte[] ) response ).length ) - + ( ( byte[] ) response ).length; + if ( response instanceof String ) + { + int responseLength = StringTools.getBytesUtf8( ( String ) response ).length; + extendedResponseLength += 1 + TLV.getNbBytes( responseLength ) + responseLength; + } + else + { + extendedResponseLength += 1 + TLV.getNbBytes( ( ( byte[] ) response ).length ) + + ( ( byte[] ) response ).length; + } } } - return 1 + Length.getNbBytes( extendedResponseLength ) + extendedResponseLength; + return 1 + TLV.getNbBytes( extendedResponseLength ) + extendedResponseLength; } /** - * Encode the ExtendedResponse message to a PDU. ExtendedResponse : - * LdapResult.encode() [0x8A LL response name] [0x8B LL response] + * Encode the ExtendedResponse message to a PDU. + * ExtendedResponse : + * LdapResult.encode() + * [0x8A LL response name] + * [0x8B LL response] * * @param buffer * The buffer where to put the PDU @@ -192,7 +197,7 @@ { // The BindResponse Tag buffer.put( LdapConstants.EXTENDED_RESPONSE_TAG ); - buffer.put( Length.getBytes( extendedResponseLength ) ); + buffer.put( TLV.getBytes( extendedResponseLength ) ); // The LdapResult super.encode( buffer ); @@ -201,7 +206,7 @@ if ( responseName != null ) { buffer.put( ( byte ) LdapConstants.EXTENDED_RESPONSE_RESPONSE_NAME_TAG ); - buffer.put( Length.getBytes( responseNameLength ) ); + buffer.put( TLV.getBytes( responseNameLength ) ); if ( responseName.getOIDLength() != 0 ) { @@ -217,7 +222,7 @@ if ( response instanceof String ) { byte[] responseBytes = StringTools.getBytesUtf8( ( String ) response ); - buffer.put( Length.getBytes( responseBytes.length ) ); + buffer.put( TLV.getBytes( responseBytes.length ) ); if ( responseBytes.length != 0 ) { @@ -226,7 +231,7 @@ } else { - buffer.put( Length.getBytes( ( ( byte[] ) response ).length ) ); + buffer.put( TLV.getBytes( ( ( byte[] ) response ).length ) ); if ( ( ( byte[] ) response ).length != 0 ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulAction.java Tue Oct 3 06:49:43 2006 @@ -58,10 +58,8 @@ /** * Create a GracefulAction object, with a timeOffline and a delay * - * @param timeOffline - * The time the server will be offline - * @param delay - * The delay before the disconnection + * @param timeOffline The time the server will be offline + * @param delay The delay before the disconnection */ public GracefulAction(int timeOffline, int delay) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnect.java Tue Oct 3 06:49:43 2006 @@ -25,7 +25,7 @@ import java.util.Iterator; import java.util.List; -import org.apache.directory.shared.asn1.ber.tlv.Length; +import org.apache.directory.shared.asn1.ber.tlv.TLV; import org.apache.directory.shared.asn1.ber.tlv.UniversalTag; import org.apache.directory.shared.asn1.ber.tlv.Value; import org.apache.directory.shared.asn1.codec.EncoderException; @@ -62,10 +62,8 @@ /** * Create a GracefulDisconnect object, with a timeOffline and a delay * - * @param timeOffline - * The time the server will be offline - * @param delay - * The delay before the disconnection + * @param timeOffline The time the server will be offline + * @param delay The delay before the disconnection */ public GracefulDisconnect(int timeOffline, int delay) { @@ -102,8 +100,7 @@ /** * Add a new URL of a replicated server * - * @param replicatedContext - * The replictaed server to add. + * @param replicatedContext The replictaed server to add. */ public void addReplicatedContexts( LdapURL replicatedContext ) { @@ -112,9 +109,15 @@ /** - * Compute the GracefulDisconnect length 0x30 L1 | +--> [ 0x02 0x0(1-4) - * [0..720] ] +--> [ 0x80 0x0(1-3) [0..86400] ] +--> [ 0x30 L2 | +--> (0x04 - * L3 value) + + * Compute the GracefulDisconnect length + * + * 0x30 L1 + * | + * +--> [ 0x02 0x0(1-4) [0..720] ] + * +--> [ 0x80 0x0(1-3) [0..86400] ] + * +--> [ 0x30 L2 + * | + * +--> (0x04 L3 value) + ] */ public int computeLength() { @@ -140,25 +143,23 @@ while ( replicatedContextIterator.hasNext() ) { int ldapUrlLength = ( ( LdapURL ) replicatedContextIterator.next() ).getNbBytes(); - replicatedContextsLength += 1 + Length.getNbBytes( ldapUrlLength ) + ldapUrlLength; + replicatedContextsLength += 1 + TLV.getNbBytes( ldapUrlLength ) + ldapUrlLength; } - gracefulDisconnectSequenceLength += 1 + Length.getNbBytes( replicatedContextsLength ) + gracefulDisconnectSequenceLength += 1 + TLV.getNbBytes( replicatedContextsLength ) + replicatedContextsLength; } - return 1 + Length.getNbBytes( gracefulDisconnectSequenceLength ) + gracefulDisconnectSequenceLength; + return 1 + TLV.getNbBytes( gracefulDisconnectSequenceLength ) + gracefulDisconnectSequenceLength; } /** * Encodes the gracefulDisconnect extended operation. * - * @param buffer - * The encoded sink + * @param buffer The encoded sink * @return A ByteBuffer that contains the encoded PDU - * @throws EncoderException - * If anything goes wrong. + * @throws EncoderException If anything goes wrong. */ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException { @@ -166,7 +167,7 @@ ByteBuffer bb = ByteBuffer.allocate( computeLength() ); bb.put( UniversalTag.SEQUENCE_TAG ); - bb.put( Length.getBytes( gracefulDisconnectSequenceLength ) ); + bb.put( TLV.getBytes( gracefulDisconnectSequenceLength ) ); if ( timeOffline != 0 ) { @@ -176,14 +177,14 @@ if ( delay != 0 ) { bb.put( ( byte ) GracefulActionConstants.GRACEFUL_ACTION_DELAY_TAG ); - bb.put( ( byte ) Length.getNbBytes( delay ) ); + bb.put( ( byte ) TLV.getNbBytes( delay ) ); bb.put( Value.getBytes( delay ) ); } if ( replicatedContexts.size() != 0 ) { bb.put( UniversalTag.SEQUENCE_TAG ); - bb.put( Length.getBytes( replicatedContextsLength ) ); + bb.put( TLV.getBytes( replicatedContextsLength ) ); Iterator replicatedContextIterator = replicatedContexts.iterator(); Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectContainer.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectContainer.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectContainer.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectContainer.java Tue Oct 3 06:49:43 2006 @@ -22,7 +22,6 @@ import org.apache.directory.shared.asn1.ber.AbstractContainer; import org.apache.directory.shared.asn1.ber.IAsn1Container; -import org.apache.directory.shared.asn1.ber.grammar.IGrammar; /** @@ -43,14 +42,8 @@ public GracefulDisconnectContainer() { super(); - currentGrammar = 0; - grammars = new IGrammar[GracefulDisconnectStatesEnum.NB_GRAMMARS]; - grammarStack = new IGrammar[1]; stateStack = new int[1]; - nbGrammars = 0; - - grammars[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_GRAMMAR] = GracefulDisconnectGrammar.getInstance(); - grammarStack[currentGrammar] = grammars[GracefulDisconnectStatesEnum.GRACEFUL_DISCONNECT_GRAMMAR]; + grammar = GracefulDisconnectGrammar.getInstance(); states = GracefulDisconnectStatesEnum.getInstance(); } @@ -68,8 +61,7 @@ * Set a GracefulDisconnect Object into the container. It will be completed * by the ldapDecoder. * - * @param control - * the GracefulShutdown to set. + * @param control the GracefulShutdown to set. */ public void setGracefulDisconnect( GracefulDisconnect gracefulDisconnect ) { Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectDecoder.java URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectDecoder.java?view=diff&rev=452497&r1=452496&r2=452497 ============================================================================== --- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectDecoder.java (original) +++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/operations/GracefulDisconnectDecoder.java Tue Oct 3 06:49:43 2006 @@ -44,11 +44,9 @@ * Decode a PDU which must contain a GracefulDisconnect extended operation. * Note that the stream of bytes much contain a full PDU, not a partial one. * - * @param stream - * The bytes to be decoded + * @param stream The bytes to be decoded * @return An GracefulDisconnect object - * @throws DecoderException - * If the decoding failed + * @throws DecoderException If the decoding failed */ public Asn1Object decode( byte[] stream ) throws DecoderException, NamingException {