();
-
-
- public ControlValueAction()
- {
- super( "Sets the control value" );
-
- ControlDecoder decoder;
- decoder = new PSearchControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
-
- decoder = new ManageDsaITControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
-
- decoder = new SubEntryControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
-
- decoder = new PagedSearchControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
-
- decoder = new SyncDoneValueControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
-
- decoder = new SyncInfoValueControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
-
- decoder = new SyncRequestValueControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
-
- decoder = new SyncStateValueControlDecoder();
- controlDecoders.put( decoder.getControlType(), decoder );
- }
-
public void action( IAsn1Container container ) throws DecoderException
{
@@ -103,32 +58,27 @@
LdapMessageCodec message = ldapMessageContainer.getLdapMessage();
// Get the current control
- ControlCodec control = message.getCurrentControl();
+ CodecControl control = message.getCurrentControl();
Value value = tlv.getValue();
- ControlDecoder decoder = controlDecoders.get( control.getControlType() );
+ ControlDecoder decoder = control.getDecoder();
// Store the value - have to handle the special case of a 0 length value
if ( tlv.getLength() == 0 )
{
- control.setControlValue( new byte[]
- {} );
+ control.setValue( StringTools.EMPTY_BYTES );
}
else
{
- Object decoded;
-
- if ( decoder != null )
+ if ( decoder == null )
{
- decoded = decoder.decode( value.getData() );
+ // No decoder : store the raw value
+ control.setValue( value.getData() );
}
else
{
- decoded = value.getData();
+ decoder.decode( value.getData(), control );
}
-
- control.setEncodedValue( value.getData() );
- control.setControlValue( decoded );
}
// We can have an END transition
@@ -136,18 +86,7 @@
if ( IS_DEBUG )
{
- if ( control.getControlValue() instanceof byte[] )
- {
- log.debug( "Control value : " + StringTools.dumpBytes( ( byte[] ) control.getControlValue() ) );
- }
- else if ( control.getControlValue() instanceof String )
- {
- log.debug( "Control value : " + ( String ) control.getControlValue() );
- }
- else
- {
- log.debug( "Control value : " + control.getControlValue() );
- }
+ log.debug( "Control value : " + StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
}
}
}
Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/AbstractControlCodec.java (from r903704, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlCodec.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/AbstractControlCodec.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/AbstractControlCodec.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlCodec.java&r1=903704&r2=905297&rev=905297&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlCodec.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/AbstractControlCodec.java Mon Feb 1 15:04:10 2010
@@ -17,14 +17,13 @@
* under the License.
*
*/
-package org.apache.directory.shared.ldap.codec;
+package org.apache.directory.shared.ldap.codec.controls;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import org.apache.directory.shared.asn1.AbstractAsn1Object;
-import org.apache.directory.shared.asn1.Asn1Object;
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;
@@ -38,25 +37,26 @@
* @author Apache Directory Project
* @version $Rev$, $Date$,
*/
-public class ControlCodec extends AbstractAsn1Object
+public abstract class AbstractControlCodec extends AbstractAsn1Object implements CodecControl
{
// ~ Instance fields
// ----------------------------------------------------------------------------
-
/** The control type */
- private String controlType;
+ private String oid;
/** The criticality (default value is false) */
private boolean criticality = false;
- /** Optionnal control value */
- private Object controlValue;
-
- /** Optionnal control value in encoded form */
- private byte[] encodedValue;
+ /** Optional control value */
+ protected byte[] value;
+
+ /** The encoded value length */
+ protected int valueLength;
/** The control length */
private int controlLength;
+
+ protected ControlDecoder decoder;
// ~ Methods
// ------------------------------------------------------------------------------------
@@ -64,30 +64,19 @@
/**
* Default constructor.
*/
- public ControlCodec()
- {
- super();
- }
-
- /**
- * Get the control type
- *
- * @return A string which represent the control type
- */
- public String getControlType()
+ public AbstractControlCodec( String oid )
{
- return controlType == null ? "" : controlType;
+ this.oid = oid;
}
-
/**
- * Set the control type
+ * Get the OID
*
- * @param controlType The OID to be stored
+ * @return A string which represent the control oid
*/
- public void setControlType( String controlType )
+ public String getOid()
{
- this.controlType = controlType;
+ return oid == null ? "" : oid;
}
@@ -96,20 +85,9 @@
*
* @return The control value
*/
- public Object getControlValue()
+ public byte[] getValue()
{
- if ( controlValue == null )
- {
- return StringTools.EMPTY_BYTES;
- }
- else if ( controlValue instanceof String )
- {
- return StringTools.getBytesUtf8( ( String ) controlValue );
- }
- else
- {
- return controlValue;
- }
+ return value;
}
@@ -118,44 +96,17 @@
*
* @param encodedValue The encoded control value to store
*/
- public void setEncodedValue( byte[] encodedValue )
+ public void setValue( byte[] value )
{
- if ( encodedValue != null )
+ if ( value != null )
{
- this.encodedValue = new byte[ encodedValue.length ];
- System.arraycopy( encodedValue, 0, this.encodedValue, 0, encodedValue.length );
- } else {
- this.encodedValue = null;
- }
- }
-
-
- /**
- * Get the raw control encoded bytes
- *
- * @return the encoded bytes for the control
- */
- public byte[] getEncodedValue()
- {
- if ( encodedValue == null )
+ this.value = new byte[ value.length ];
+ System.arraycopy( value, 0, this.value, 0, value.length );
+ }
+ else
{
- return StringTools.EMPTY_BYTES;
+ this.value = null;
}
-
- final byte[] copy = new byte[ encodedValue.length ];
- System.arraycopy( encodedValue, 0, copy, 0, encodedValue.length );
- return copy;
- }
-
-
- /**
- * Set the control value
- *
- * @param controlValue The control value to store
- */
- public void setControlValue( Object controlValue )
- {
- this.controlValue = controlValue;
}
@@ -164,7 +115,7 @@
*
* @return true if the criticality flag is true.
*/
- public boolean getCriticality()
+ public boolean isCritical()
{
return criticality;
}
@@ -175,32 +126,29 @@
*
* @param criticality The criticality value
*/
- public void setCriticality( boolean criticality )
+ public void setCritical( boolean criticality )
{
this.criticality = criticality;
}
-
+
/**
- * Compute the Control length
- * Control :
- *
- * 0x30 L1
- * |
- * +--> 0x04 L2 controlType
- * [+--> 0x01 0x01 criticality]
- * [+--> 0x04 L3 controlValue]
- *
- * Control length = Length(0x30) + length(L1)
- * + Length(0x04) + Length(L2) + L2
- * [+ Length(0x01) + 1 + 1]
- * [+ Length(0x04) + Length(L3) + L3]
+ * {@inheritDoc}
*/
public int computeLength()
{
- // The controlType
- int controlTypeLengh = StringTools.getBytesUtf8( controlType ).length;
- controlLength = 1 + TLV.getNbBytes( controlTypeLengh ) + controlTypeLengh;
+ return 0;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int computeLength( int valueLength )
+ {
+ // The OID
+ int oidLengh = StringTools.getBytesUtf8( oid ).length;
+ controlLength = 1 + TLV.getNbBytes( oidLengh ) + oidLengh;
// The criticality, only if true
if ( criticality )
@@ -208,50 +156,27 @@
controlLength += 1 + 1 + 1; // Always 3 for a boolean
}
- // The control value, if any
- if ( controlValue != null )
+ this.valueLength = valueLength;
+
+ if ( valueLength != 0 )
{
- byte[] controlBytes;
- if ( controlValue instanceof byte[] )
- {
- controlBytes = ( byte[] ) controlValue;
- controlLength += 1 + TLV.getNbBytes( controlBytes.length ) + controlBytes.length;
- }
- else if ( controlValue instanceof String )
- {
- controlBytes = StringTools.getBytesUtf8( ( String ) controlValue );
- controlLength += 1 + TLV.getNbBytes( controlBytes.length ) + controlBytes.length;
- }
- else if ( controlValue instanceof Asn1Object )
- {
- int length = ( ( Asn1Object ) controlValue ).computeLength();
- controlLength += 1 + TLV.getNbBytes( length ) + length;
- }
- else
- {
- throw new IllegalStateException( "Don't know how to handle control value class "
- + controlValue.getClass() );
- }
+ controlLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
}
-
+
return 1 + TLV.getNbBytes( controlLength ) + controlLength;
}
/**
- * Generate the PDU which contains the Control.
- * Control :
- * 0x30 LL
- * 0x04 LL type
- * [0x01 0x01 criticality]
- * [0x04 LL value]
- *
- * @param buffer The encoded PDU
- * @return A ByteBuffer that contaons the PDU
- * @throws EncoderException If anything goes wrong.
+ * {@inheritDoc}
*/
public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
{
+ if ( buffer == null )
+ {
+ throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+ }
+
try
{
// The LdapMessage Sequence
@@ -266,7 +191,7 @@
}
// The control type
- Value.encode( buffer, getControlType().getBytes() );
+ Value.encode( buffer, getOid().getBytes() );
// The control criticality, if true
if ( criticality )
@@ -274,36 +199,23 @@
Value.encode( buffer, criticality );
}
- // The control value, if any
- if ( controlValue != null )
- {
- byte[] controlBytes;
- if ( controlValue instanceof byte[] )
- {
- controlBytes = ( byte[] ) controlValue;
- encodedValue = controlBytes;
- }
- else if ( controlValue instanceof String )
- {
- controlBytes = StringTools.getBytesUtf8( ( String ) controlValue );
- encodedValue = controlBytes;
- }
- else if ( controlValue instanceof Asn1Object )
- {
- controlBytes = ( ( Asn1Object ) controlValue ).encode( null ).array();
- encodedValue = controlBytes;
- }
- else
- {
- throw new IllegalStateException( "Don't know how to handle control value class "
- + controlValue.getClass() );
- }
-
- Value.encode( buffer, controlBytes );
- }
-
return buffer;
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasValue()
+ {
+ return value != null;
+ }
+
+
+ public ControlDecoder getDecoder()
+ {
+ return decoder;
+ }
/**
@@ -314,21 +226,14 @@
StringBuffer sb = new StringBuffer();
sb.append( " Control\n" );
- sb.append( " Control type : '" ).append( controlType ).append(
+ sb.append( " Control oid : '" ).append( oid ).append(
"'\n" );
sb.append( " Criticality : '" ).append( criticality ).append( "'\n" );
- if ( controlValue != null )
+ if ( value != null )
{
- if ( controlValue instanceof byte[] )
- {
- sb.append( " Control value : '" ).append( StringTools.dumpBytes( ( byte[] ) controlValue ) )
- .append( "'\n" );
- }
- else
- {
- sb.append( " Control value : '" ).append( controlValue ).append( "'\n" );
- }
+ sb.append( " Control value : '" ).append( StringTools.dumpBytes( value ) )
+ .append( "'\n" );
}
return sb.toString();
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlCodec.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlCodec.java?rev=905297&r1=905296&r2=905297&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlCodec.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlCodec.java Mon Feb 1 15:04:10 2010
@@ -20,10 +20,6 @@
package org.apache.directory.shared.ldap.codec.controls;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.shared.asn1.AbstractAsn1Object;
-import org.apache.directory.shared.asn1.codec.EncoderException;
/**
@@ -31,9 +27,10 @@
* @author Apache Directory Project
* @version $Rev$
*/
-public class CascadeControlCodec extends AbstractAsn1Object
+public class CascadeControlCodec extends AbstractControlCodec
{
- private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate( 0 );
+ /** The cascade control OID */
+ public static final String CONTROL_OID = "1.3.6.1.4.1.18060.0.0.1";
/**
* Default constructor
@@ -41,23 +38,33 @@
*/
public CascadeControlCodec()
{
- super();
+ super( CONTROL_OID );
+
+ decoder = new CascadeControlDecoder();
}
+
/**
- * Returns 0 everytime.
+ * Returns the default control length.
*/
public int computeLength()
{
- return 0;
+ // Call the super class to compute the global control length
+ return super.computeLength( 0 );
}
-
+
/**
- * Encodes the control: does nothing but returns an empty buffer.
+ * Return a String representing this Cascade Control.
*/
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+ public String toString()
{
- return EMPTY_BUFFER;
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( " Cascade Control\n" );
+ sb.append( " oid : " ).append( getOid() ).append( '\n' );
+ sb.append( " critical : " ).append( isCritical() ).append( '\n' );
+
+ return sb.toString();
}
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlDecoder.java?rev=905297&r1=905296&r2=905297&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlDecoder.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CascadeControlDecoder.java Mon Feb 1 15:04:10 2010
@@ -22,8 +22,6 @@
import org.apache.directory.shared.asn1.Asn1Object;
import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.ldap.codec.ControlDecoder;
-import org.apache.directory.shared.ldap.message.control.CascadeControl;
/**
@@ -34,13 +32,7 @@
*/
public class CascadeControlDecoder implements ControlDecoder
{
- public String getControlType()
- {
- return CascadeControl.CONTROL_OID;
- }
-
-
- public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+ public Asn1Object decode( byte[] controlBytes, CodecControl control ) throws DecoderException
{
return new CascadeControlCodec();
}
Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControl.java?rev=905297&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControl.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControl.java Mon Feb 1 15:04:10 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.controls;
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.message.control.Control;
+
+/**
+ * Define the transform method to be implemented by all the codec Controls
+ *
+ * @author Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public interface CodecControl extends Control
+{
+ /**
+ * Generate the PDU which contains the Control.
+ *
+ * Control :
+ *
+ * 0x30 LL
+ * 0x04 LL type
+ * [0x01 0x01 criticality]
+ * [0x04 LL value]
+ *
+ * @param buffer The encoded PDU
+ * @return A ByteBuffer that contaons the PDU
+ * @throws EncoderException If anything goes wrong.
+ */
+ ByteBuffer encode( ByteBuffer buffer ) throws EncoderException;
+
+
+ /**
+ * Compute the Control length
+ *
+ * Control :
+ *
+ * 0x30 L1
+ * |
+ * +--> 0x04 L2 controlType
+ * [+--> 0x01 0x01 criticality]
+ * [+--> 0x04 L3 controlValue]
+ *
+ * Control length = Length(0x30) + length(L1)
+ * + Length(0x04) + Length(L2) + L2
+ * [+ Length(0x01) + 1 + 1]
+ * [+ Length(0x04) + Length(L3) + L3]
+ *
+ */
+ int computeLength();
+
+ /**
+ * Get the associated decoder
+ *
+ * @return The Control decoder
+ */
+ ControlDecoder getDecoder();
+}
Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControlImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControlImpl.java?rev=905297&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControlImpl.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/CodecControlImpl.java Mon Feb 1 15:04:10 2010
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.controls;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A genericcodec Control.
+ *
+ * @author Apache Directory Project
+ * @version $Rev: 764131 $, $Date: 2009-04-11 03:03:00 +0200 (Sat, 11 Apr 2009) $,
+ */
+public class CodecControlImpl extends AbstractControlCodec
+{
+ /**
+ * Default constructor.
+ */
+ public CodecControlImpl( String oid )
+ {
+ super( oid );
+
+ decoder = null;
+ }
+
+
+ /**
+ * Set the encoded control value
+ *
+ * @param encodedValue The encoded control value to store
+ */
+ public void setValue( byte[] value )
+ {
+ if ( value != null )
+ {
+ this.value = new byte[ value.length ];
+ System.arraycopy( value, 0, this.value, 0, value.length );
+ }
+ else
+ {
+ this.value = null;
+ }
+ }
+
+
+ /**
+ * Get the raw control encoded bytes
+ *
+ * @return the encoded bytes for the control
+ */
+ public byte[] getValue()
+ {
+ if ( value == null )
+ {
+ return StringTools.EMPTY_BYTES;
+ }
+
+ final byte[] copy = new byte[ value.length ];
+ System.arraycopy( value, 0, copy, 0, value.length );
+ return copy;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int computeLength()
+ {
+ if ( value != null )
+ {
+ return super.computeLength( value.length );
+ }
+ else
+ {
+ return super.computeLength( 0 );
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+ {
+ if ( buffer == null )
+ {
+ throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+ }
+
+ // Encode the Control envelop
+ super.encode( buffer );
+
+ // If we have a value, encode it
+ if ( value != null )
+ {
+ Value.encode( buffer, value );
+ }
+
+ return buffer;
+ }
+}
Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecoder.java (from r903704, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlDecoder.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecoder.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecoder.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlDecoder.java&r1=903704&r2=905297&rev=905297&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ControlDecoder.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ControlDecoder.java Mon Feb 1 15:04:10 2010
@@ -17,7 +17,7 @@
* under the License.
*
*/
-package org.apache.directory.shared.ldap.codec;
+package org.apache.directory.shared.ldap.codec.controls;
import org.apache.directory.shared.asn1.Asn1Object;
@@ -33,19 +33,12 @@
public interface ControlDecoder
{
/**
- * The control type this decoder decodes.
- *
- * @return the control type (an OID string)
- */
- String getControlType();
-
-
- /**
* Decodes raw ASN.1 encoded bytes into an Asn1Object for the control.
*
* @param controlBytes the encoded control bytes
+ * @param control The control to feed
* @return the decoded Asn1Object for the control
* @throws DecoderException if anything goes wrong
*/
- Asn1Object decode( byte[] controlBytes ) throws DecoderException;
+ Asn1Object decode( byte[] controlBytes, CodecControl control ) throws DecoderException;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlCodec.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlCodec.java?rev=905297&r1=905296&r2=905297&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlCodec.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlCodec.java Mon Feb 1 15:04:10 2010
@@ -20,10 +20,6 @@
package org.apache.directory.shared.ldap.codec.controls;
-import java.nio.ByteBuffer;
-
-import org.apache.directory.shared.asn1.AbstractAsn1Object;
-import org.apache.directory.shared.asn1.codec.EncoderException;
/**
@@ -64,9 +60,10 @@
* @author Apache Directory Project
* @version $Rev$
*/
-public class ManageDsaITControlCodec extends AbstractAsn1Object
+public class ManageDsaITControlCodec extends AbstractControlCodec
{
- private static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate( 0 );
+ /** This control OID */
+ public static final String CONTROL_OID = "2.16.840.1.113730.3.4.2";
/**
* Default constructor
@@ -74,23 +71,32 @@
*/
public ManageDsaITControlCodec()
{
- super();
+ super( CONTROL_OID );
+
+ decoder = new ManageDsaITControlDecoder();
}
/**
- * Returns 0 everytime.
+ * Returns 0 every time.
*/
public int computeLength()
{
- return 0;
+ // Call the super class to compute the global control length
+ return super.computeLength( 0 );
}
/**
- * Encodes the control: does nothing but returns an empty buffer.
+ * Return a String representing this ManageDsaIt Control.
*/
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+ public String toString()
{
- return EMPTY_BUFFER;
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( " ManageDsaIt Control\n" );
+ sb.append( " oid : " ).append( getOid() ).append( '\n' );
+ sb.append( " critical : " ).append( isCritical() ).append( '\n' );
+
+ return sb.toString();
}
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlDecoder.java?rev=905297&r1=905296&r2=905297&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlDecoder.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ManageDsaITControlDecoder.java Mon Feb 1 15:04:10 2010
@@ -22,8 +22,6 @@
import org.apache.directory.shared.asn1.Asn1Object;
import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.ldap.codec.ControlDecoder;
-import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
/**
@@ -34,13 +32,7 @@
*/
public class ManageDsaITControlDecoder implements ControlDecoder
{
- public String getControlType()
- {
- return ManageDsaITControl.CONTROL_OID;
- }
-
-
- public Asn1Object decode( byte[] controlBytes ) throws DecoderException
+ public Asn1Object decode( byte[] controlBytes, CodecControl control ) throws DecoderException
{
return new ManageDsaITControlCodec();
}