Uploaded image for project: 'Directory Client API'
  1. Directory Client API
  2. DIRAPI-139

o.a.d.api.ldap.codec.api.LdapEncoder should log encoded PDU via DEBUG

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0-M17
    • 1.0.0-M18
    • None

    Description

      o.a.d.api.ldap.codec.api.LdapDecoder has a nice feature to output the PDU :

      13:30:25.933 [NioProcessor-1] DEBUG o.a.d.api.ldap.codec.api.LdapDecoder - Decoding the PDU : 
      13:30:25.934 [NioProcessor-1] DEBUG o.a.d.api.ldap.codec.api.LdapDecoder - 0x30 0x32 0x02 0x01 0x02 0x65 0x2D 0x0A 0x01 0x02 0x04 0x00 0x04 0x26 0x73 0x6F 0x72 0x74 0x65 0x64 0x20 0x72 0x65 0x73 0x75 0x6C 0x74 0x73 0x20 0x63 0x6F 0x6E 0x74 0x72 0x6F 0x6C 0x20 0x76 0x61 0x6C 0x75 0x65 0x20 0x69 0x73 0x20 0x61 0x62 0x73 0x65 0x6E 0x74 
      

      However LdapEncoder doesn't do this, although LdapNetworkConnection outputs a textual form: (note the "-----" divider is superfluous, can it be removed?)

      13:30:25.932 [main] DEBUG o.a.d.l.c.api.LdapNetworkConnection - -----------------------------------------------------------------
      13:30:25.933 [main] DEBUG o.a.d.l.c.api.LdapNetworkConnection - Sending request 
      MessageType : SEARCH_REQUEST
      Message ID : 2
          SearchRequest
              baseDn : 'dc=dev,dc=tuneeca,dc=com'
              filter : '(sn=*)'
              scope : single level
              typesOnly : false
              Size Limit : no limit
              Time Limit : no limit
              Deref Aliases : deref Always
              attributes : 
      org.apache.directory.api.ldap.model.message.SearchRequestImpl@25dcb2bc    ServerSideSort Control
              Type OID    : '1.2.840.113556.1.4.473'
              Criticality : 'false'
      '
      

      I had to use code (while trying to implement #DIRAPI-137) such as:

      SearchRequestImpl search = new SearchRequestImpl();
      //						search.setBase(new Dn(baseDn));
      search.setBase(new Dn("dc=dev,dc=tuneeca,dc=com"));
      search.setFilter(filter);
      search.setScope(SearchScope.ONELEVEL);
      String sortProperty = pageable.getSort().iterator().next().getProperty();
      ServerSideSort skl = new ServerSideSort(sortProperty);
      search.addControl(skl);
      
      // debug stuff
      ProtocolCodecSession session = new ProtocolCodecSession();
      ProtocolEncoder encoder = new LdapProtocolEncoder();
      encoder.encode(session, search, session.getEncoderOutput());
      IoBuffer buffer = (IoBuffer) session.getEncoderOutputQueue().poll();
      HexDump.dump(buffer.array(), 0, System.out, 0);
      // debug stuff
      

      In order to get output such as:

      00000000 30 50 02 01 FF 63 2F 04 18 64 63 3D 64 65 76 2C 0P...c/..dc=dev,
      00000010 64 63 3D 74 75 6E 65 65 63 61 2C 64 63 3D 63 6F dc=tuneeca,dc=co
      00000020 6D 0A 01 01 0A 01 03 02 01 00 02 01 00 01 01 00 m...............
      00000030 87 02 73 6E 30 00 A0 1A 30 18 04 16 31 2E 32 2E ..sn0...0...1.2.
      00000040 38 34 30 2E 31 31 33 35 35 36 2E 31 2E 34 2E 34 840.113556.1.4.4
      00000050 37 33                                           73
      

      It would be great if o.a.d.api.ldap.codec.api.LdapEncoder can do this using log DEBUG.

      Attachments

        Issue Links

          Activity

            People

              elecharny Emmanuel Lécharny
              ceefour Hendy Irawan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: