*/
public void decode( IoSession session, IoBuffer buffer, ProtocolDecoderOutput out ) throws Exception
{
// Allocate a LdapMessage Container
Asn1Decoder ldapDecoder = new Asn1Decoder();
IAsn1Container ldapMessageContainer = (LdapMessageContainer)session.getAttribute( "LDAP-Container" );
ByteBuffer buf = buffer.buf();
int currentPos = 0;
while ( buf.hasRemaining() )
{
try
{
ldapDecoder.decode( buf, ldapMessageContainer );
if ( IS_DEBUG )
{
LOG.debug( "Decoding the PDU : " );
int pos = buf.position();
byte[] b = new byte[pos-currentPos];
System.arraycopy( buf.array(), currentPos, b, 0, pos-currentPos );
currentPos = pos;
System.out.println( "Received buffer : " + StringTools.dumpBytes( b ) );
}
if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
{
// get back the decoded message
LdapMessageCodec message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
if ( IS_DEBUG )