Example #1
0
  /**
   * Reads an LDAP message from the associated input stream.
   *
   * @return The LDAP message read from the associated input stream, or <CODE>null</CODE> if the end
   *     of the stream has been reached.
   * @throws IOException If a problem occurs while attempting to read from the input stream.
   * @throws ASN1Exception If a problem occurs while attempting to decode the data read as an ASN.1
   *     sequence.
   * @throws LDAPException If a problem occurs while attempting to decode the LDAP message.
   */
  public LDAPMessage readMessage() throws IOException, ASN1Exception, LDAPException {
    debugInputStream.setRecordingEnabled(debugEnabled());

    if (!asn1Reader.hasNextElement()) {
      // EOF was reached...
      return null;
    }

    LDAPMessage message = org.opends.server.protocols.ldap.LDAPReader.readMessage(asn1Reader);

    if (debugInputStream.isRecordingEnabled()) {
      ByteString bytesRead = debugInputStream.getRecordedBytes();
      debugInputStream.clearRecordedBytes();

      StringBuilder builder = new StringBuilder();
      builder.append("bytes read from wire(len=");
      builder.append(bytesRead.length());
      builder.append("):");
      builder.append(ServerConstants.EOL);
      bytesRead.toHexPlusAscii(builder, 4);

      TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, builder.toString());
      TRACER.debugProtocolElement(DebugLogLevel.VERBOSE, message.toString());
    }

    return message;
  }