Search in sources :

Example 71 with JSONBuffer

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

the class JSONLDAPConnectionLogger method logConnectFailure.

/**
 * {@inheritDoc}
 */
@Override()
public void logConnectFailure(@NotNull final LDAPConnectionInfo connectionInfo, @NotNull final String host, final int port, @NotNull final LDAPException connectException) {
    if (logConnects) {
        final JSONBuffer buffer = startLogMessage("connect-failure", null, connectionInfo, -1);
        buffer.appendString("hostname", host);
        buffer.appendNumber("port", port);
        if (connectException != null) {
            appendException(buffer, "connect-exception", connectException);
        }
        logMessage(buffer, flushAfterConnectMessages);
    }
}
Also used : JSONBuffer(com.unboundid.util.json.JSONBuffer)

Example 72 with JSONBuffer

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

the class JSONLDAPConnectionLogger method logSearchEntry.

/**
 * {@inheritDoc}
 */
@Override()
public void logSearchEntry(@NotNull final LDAPConnectionInfo connectionInfo, final int requestMessageID, @NotNull final SearchResultEntry searchEntry) {
    if (logSearchEntries && operationTypes.contains(OperationType.SEARCH)) {
        final JSONBuffer buffer = startLogMessage("search-entry", OperationType.SEARCH, connectionInfo, requestMessageID);
        appendDN(buffer, "dn", searchEntry.getDN());
        if (includeSearchEntryAttributeNames) {
            appendAttributes(buffer, "attributes", new ArrayList<>(searchEntry.getAttributes()), includeSearchEntryAttributeValues);
        }
        appendControls(buffer, "control-oids", searchEntry.getControls());
        logMessage(buffer, flushAfterRequestMessages);
    }
}
Also used : JSONBuffer(com.unboundid.util.json.JSONBuffer)

Example 73 with JSONBuffer

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

the class JSONLDAPResultWriter method toJSON.

/**
 * Encodes the provided search result reference as a JSON object.
 *
 * @param  ref  The search result reference to be encoded as a JSON object.
 *              It must not be {@code null}.
 *
 * @return  The JSON object containing the encoded representation of the
 *          search result reference.
 */
@NotNull()
public static JSONObject toJSON(@NotNull final SearchResultReference ref) {
    try {
        final JSONBuffer jsonBuffer = new JSONBuffer();
        toJSON(ref, jsonBuffer);
        return jsonBuffer.toJSONObject();
    } catch (final JSONException e) {
        // This should never happen.
        Debug.debugException(e);
        throw new LDAPRuntimeException(new LDAPException(ResultCode.ENCODING_ERROR, e.getMessage(), e));
    }
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) JSONBuffer(com.unboundid.util.json.JSONBuffer) JSONException(com.unboundid.util.json.JSONException) LDAPRuntimeException(com.unboundid.ldap.sdk.LDAPRuntimeException) NotNull(com.unboundid.util.NotNull)

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