Search in sources :

Example 51 with JSONBuffer

use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.

the class Debug method debugASN1Write.

/**
 * Writes debug information about the provided ASN.1 element to be written,
 * if appropriate.
 *
 * @param  l  The log level that should be used for the debug information.
 * @param  b  The ASN1Buffer with the information to be written.
 */
public static void debugASN1Write(@NotNull final Level l, @NotNull final ASN1Buffer b) {
    if (debugEnabled && debugTypes.contains(DebugType.ASN1)) {
        final JSONBuffer buffer = new JSONBuffer();
        addCommonHeader(buffer, l, DebugType.ASN1);
        buffer.appendString("writing-asn1-element", StaticUtils.toHex(b.toByteArray()));
        addCommonFooter(buffer);
        log(l, buffer);
    }
}
Also used : JSONBuffer(com.unboundid.util.json.JSONBuffer)

Example 52 with JSONBuffer

use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.

the class Debug method debugASN1Read.

/**
 * Writes debug information about the provided ASN.1 element that was read, if
 * appropriate.
 *
 * @param  l  The log level that should be used for the debug information.
 * @param  e  The ASN.1 element for which debug information should be written.
 */
public static void debugASN1Read(@NotNull final Level l, @NotNull final ASN1Element e) {
    if (debugEnabled && debugTypes.contains(DebugType.ASN1)) {
        final JSONBuffer buffer = new JSONBuffer();
        addCommonHeader(buffer, l, DebugType.ASN1);
        buffer.appendString("read-asn1-element", e.toString());
        addCommonFooter(buffer);
        log(l, buffer);
    }
}
Also used : JSONBuffer(com.unboundid.util.json.JSONBuffer)

Example 53 with JSONBuffer

use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.

the class Debug method debugLDIFRead.

/**
 * Writes debug information about the provided record read from LDIF, if
 * appropriate.
 *
 * @param  l  The log level that should be used for the debug information.
 * @param  r  The LDIF record for which debug information should be written.
 */
public static void debugLDIFRead(@NotNull final Level l, @NotNull final LDIFRecord r) {
    if (debugEnabled && debugTypes.contains(DebugType.LDIF)) {
        final JSONBuffer buffer = new JSONBuffer();
        addCommonHeader(buffer, l, DebugType.LDIF);
        buffer.appendString("read-ldif-record", r.toString());
        addCommonFooter(buffer);
        log(l, buffer);
    }
}
Also used : JSONBuffer(com.unboundid.util.json.JSONBuffer)

Example 54 with JSONBuffer

use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.

the class Debug method debugLDIFWrite.

/**
 * Writes debug information about the provided LDIF record to be written, if
 * appropriate.
 *
 * @param  l  The log level that should be used for the debug information.
 * @param  r  The LDIF record for which debug information should be written.
 */
public static void debugLDIFWrite(@NotNull final Level l, @NotNull final LDIFRecord r) {
    if (debugEnabled && debugTypes.contains(DebugType.LDIF)) {
        final JSONBuffer buffer = new JSONBuffer();
        addCommonHeader(buffer, l, DebugType.LDIF);
        buffer.appendString("writing-ldif-record", r.toString());
        addCommonFooter(buffer);
        log(l, buffer);
    }
}
Also used : JSONBuffer(com.unboundid.util.json.JSONBuffer)

Example 55 with JSONBuffer

use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.

the class Debug method debugLDAPResult.

/**
 * Writes debug information about the provided result, if appropriate.
 *
 * @param  l  The log level that should be used for the debug information.
 * @param  r  The result for which debug information should be written.
 * @param  c  The connection on which the response was received.  It may be
 *            {@code null} for historic reasons, but should be
 *            non-{@code null} in new uses.
 */
public static void debugLDAPResult(@NotNull final Level l, @NotNull final LDAPResponse r, @Nullable final LDAPConnection c) {
    if (debugEnabled && debugTypes.contains(DebugType.LDAP)) {
        final JSONBuffer buffer = new JSONBuffer();
        addCommonHeader(buffer, l, DebugType.LDAP);
        if (c != null) {
            buffer.appendNumber("connection-id", c.getConnectionID());
            final String connectionName = c.getConnectionName();
            if (connectionName != null) {
                buffer.appendString("connection-name", connectionName);
            }
            final String connectionPoolName = c.getConnectionPoolName();
            if (connectionPoolName != null) {
                buffer.appendString("connection-pool-name", connectionPoolName);
            }
            final String connectedAddress = c.getConnectedAddress();
            if (connectedAddress != null) {
                buffer.appendString("connected-to-address", connectedAddress);
                buffer.appendNumber("connected-to-port", c.getConnectedPort());
            }
        }
        buffer.appendString("read-ldap-result", r.toString());
        addCommonFooter(buffer);
        log(l, buffer);
    }
}
Also used : JSONBuffer(com.unboundid.util.json.JSONBuffer)

Aggregations

JSONBuffer (com.unboundid.util.json.JSONBuffer)73 Test (org.testng.annotations.Test)20 NotNull (com.unboundid.util.NotNull)16 LogRecord (java.util.logging.LogRecord)12 LDAPMessage (com.unboundid.ldap.protocol.LDAPMessage)8 Date (java.util.Date)5 LDAPException (com.unboundid.ldap.sdk.LDAPException)3 LDAPRuntimeException (com.unboundid.ldap.sdk.LDAPRuntimeException)3 JSONException (com.unboundid.util.json.JSONException)3 DN (com.unboundid.ldap.sdk.DN)2 RDN (com.unboundid.ldap.sdk.RDN)2 JSONField (com.unboundid.util.json.JSONField)2 JSONObject (com.unboundid.util.json.JSONObject)2 JSONString (com.unboundid.util.json.JSONString)2 AddResponseProtocolOp (com.unboundid.ldap.protocol.AddResponseProtocolOp)1 BindResponseProtocolOp (com.unboundid.ldap.protocol.BindResponseProtocolOp)1 CompareResponseProtocolOp (com.unboundid.ldap.protocol.CompareResponseProtocolOp)1 DeleteResponseProtocolOp (com.unboundid.ldap.protocol.DeleteResponseProtocolOp)1 ExtendedResponseProtocolOp (com.unboundid.ldap.protocol.ExtendedResponseProtocolOp)1 ModifyDNResponseProtocolOp (com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp)1