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);
}
}
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);
}
}
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));
}
}
Aggregations