use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class JSONLDAPConnectionLogger method logBindRequest.
/**
* {@inheritDoc}
*/
@Override()
public void logBindRequest(@NotNull final LDAPConnectionInfo connectionInfo, final int messageID, @NotNull final SASLBindRequest bindRequest) {
if (logRequests && operationTypes.contains(OperationType.BIND)) {
final JSONBuffer buffer = startLogMessage("request", OperationType.BIND, connectionInfo, messageID);
buffer.appendString("authentication-type", "SASL");
buffer.appendString("sasl-mechanism", bindRequest.getSASLMechanismName());
appendControls(buffer, "control-oids", bindRequest.getControls());
logMessage(buffer, flushAfterRequestMessages);
}
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class JSONLDAPConnectionLogger method logBindRequest.
/**
* {@inheritDoc}
*/
@Override()
public void logBindRequest(@NotNull final LDAPConnectionInfo connectionInfo, final int messageID, @NotNull final SimpleBindRequest bindRequest) {
if (logRequests && operationTypes.contains(OperationType.BIND)) {
final JSONBuffer buffer = startLogMessage("request", OperationType.BIND, connectionInfo, messageID);
buffer.appendString("authentication-type", "simple");
appendDN(buffer, "dn", bindRequest.getBindDN());
appendControls(buffer, "control-oids", bindRequest.getControls());
logMessage(buffer, flushAfterRequestMessages);
}
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class JSONAccessLogRequestHandler method newInstance.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public JSONAccessLogRequestHandler newInstance(@NotNull final LDAPListenerClientConnection connection) throws LDAPException {
final JSONAccessLogRequestHandler h = new JSONAccessLogRequestHandler(logHandler, requestHandler.newInstance(connection), connection, jsonBuffers, timestampFormatters, decimalFormatters);
connection.addSearchEntryTransformer(h);
final JSONBuffer buffer = h.getConnectionHeader("connect");
final Socket s = connection.getSocket();
buffer.appendString("from-address", s.getInetAddress().getHostAddress());
buffer.appendNumber("from-port", s.getPort());
buffer.appendString("to-address", s.getLocalAddress().getHostAddress());
buffer.appendNumber("to-port", s.getLocalPort());
buffer.endObject();
logHandler.publish(new LogRecord(Level.INFO, buffer.toString()));
logHandler.flush();
return h;
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class JSONAccessLogRequestHandler method processAddRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processAddRequest(final int messageID, @NotNull final AddRequestProtocolOp request, @NotNull final List<Control> controls) {
final long opID = nextOperationID.getAndIncrement();
final JSONBuffer buffer = getRequestHeader("add", opID, messageID);
buffer.appendString("dn", request.getDN());
buffer.endObject();
logHandler.publish(new LogRecord(Level.INFO, buffer.toString()));
logHandler.flush();
final long startTimeNanos = System.nanoTime();
final LDAPMessage responseMessage = requestHandler.processAddRequest(messageID, request, controls);
final long eTimeNanos = System.nanoTime() - startTimeNanos;
final AddResponseProtocolOp protocolOp = responseMessage.getAddResponseProtocolOp();
generateResponse(buffer, "add", opID, messageID, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs(), eTimeNanos);
buffer.endObject();
logHandler.publish(new LogRecord(Level.INFO, buffer.toString()));
logHandler.flush();
return responseMessage;
}
use of com.unboundid.util.json.JSONBuffer in project ldapsdk by pingidentity.
the class JSONAccessLogRequestHandler method processExtendedRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processExtendedRequest(final int messageID, @NotNull final ExtendedRequestProtocolOp request, @NotNull final List<Control> controls) {
final long opID = nextOperationID.getAndIncrement();
final JSONBuffer buffer = getRequestHeader("extended", opID, messageID);
buffer.appendString("request-oid", request.getOID());
buffer.endObject();
logHandler.publish(new LogRecord(Level.INFO, buffer.toString()));
logHandler.flush();
final long startTimeNanos = System.nanoTime();
final LDAPMessage responseMessage = requestHandler.processExtendedRequest(messageID, request, controls);
final long eTimeNanos = System.nanoTime() - startTimeNanos;
final ExtendedResponseProtocolOp protocolOp = responseMessage.getExtendedResponseProtocolOp();
generateResponse(buffer, "extended", opID, messageID, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs(), eTimeNanos);
final String responseOID = protocolOp.getResponseOID();
if (responseOID != null) {
buffer.appendString("response-oid", responseOID);
}
buffer.endObject();
logHandler.publish(new LogRecord(Level.INFO, buffer.toString()));
logHandler.flush();
return responseMessage;
}
Aggregations